mirror of
https://github.com/cassoule/flopobot_v2.git
synced 2026-01-18 16:37:40 +01:00
fix: big fix + prettier
This commit is contained in:
56
index.js
56
index.js
@@ -1,53 +1,51 @@
|
||||
import 'dotenv/config';
|
||||
import http from 'http';
|
||||
import { Server } from 'socket.io';
|
||||
import "dotenv/config";
|
||||
import http from "http";
|
||||
import { Server } from "socket.io";
|
||||
|
||||
import { app } from './src/server/app.js';
|
||||
import { client } from './src/bot/client.js';
|
||||
import { initializeEvents } from './src/bot/events.js';
|
||||
import { initializeSocket } from './src/server/socket.js';
|
||||
import { getAkhys, setupCronJobs } from './src/utils/index.js';
|
||||
import { app } from "./src/server/app.js";
|
||||
import { client } from "./src/bot/client.js";
|
||||
import { initializeEvents } from "./src/bot/events.js";
|
||||
import { initializeSocket } from "./src/server/socket.js";
|
||||
import { setupCronJobs } from "./src/utils/index.js";
|
||||
|
||||
// --- SERVER INITIALIZATION ---
|
||||
const PORT = process.env.PORT || 25578;
|
||||
const server = http.createServer(app);
|
||||
|
||||
// --- SOCKET.IO INITIALIZATION ---
|
||||
const FLAPI_URL = process.env.DEV_SITE === 'true' ? process.env.FLAPI_URL_DEV : process.env.FLAPI_URL;
|
||||
const FLAPI_URL = process.env.DEV_SITE === "true" ? process.env.FLAPI_URL_DEV : process.env.FLAPI_URL;
|
||||
export const io = new Server(server, {
|
||||
cors: {
|
||||
origin: FLAPI_URL,
|
||||
methods: ['GET', 'POST', 'PUT', 'OPTIONS'],
|
||||
},
|
||||
pingInterval: 5000,
|
||||
pingTimeout: 5000,
|
||||
cors: {
|
||||
origin: FLAPI_URL,
|
||||
methods: ["GET", "POST", "PUT", "OPTIONS"],
|
||||
},
|
||||
pingInterval: 5000,
|
||||
pingTimeout: 5000,
|
||||
});
|
||||
initializeSocket(io, client);
|
||||
|
||||
|
||||
// --- BOT INITIALIZATION ---
|
||||
initializeEvents(client, io);
|
||||
client.login(process.env.BOT_TOKEN).then(() => {
|
||||
console.log(`Logged in as ${client.user.tag}`);
|
||||
console.log('[Discord Bot Events Initialized]');
|
||||
console.log(`Logged in as ${client.user.tag}`);
|
||||
console.log("[Discord Bot Events Initialized]");
|
||||
});
|
||||
|
||||
|
||||
// --- APP STARTUP ---
|
||||
server.listen(PORT, async () => {
|
||||
console.log(`Express+Socket.IO server listening on port ${PORT}`);
|
||||
console.log(`[Connected with ${FLAPI_URL}]`);
|
||||
console.log(`Express+Socket.IO server listening on port ${PORT}`);
|
||||
console.log(`[Connected with ${FLAPI_URL}]`);
|
||||
|
||||
// Initial data fetch and setup
|
||||
try {
|
||||
// Initial data fetch and setup
|
||||
/*try {
|
||||
await getAkhys(client);
|
||||
} catch (error) {
|
||||
console.log('Initial Fetch Error');
|
||||
}
|
||||
}*/
|
||||
|
||||
// Setup scheduled tasks
|
||||
//setupCronJobs(client, io);
|
||||
console.log('[Cron Jobs Initialized]');
|
||||
// Setup scheduled tasks
|
||||
setupCronJobs(client, io);
|
||||
console.log("[Cron Jobs Initialized]");
|
||||
|
||||
console.log('--- FlopoBOT is ready ---');
|
||||
});
|
||||
console.log("--- FlopoBOT is ready ---");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user