2022-11-20 13:00:00 +07:00
|
|
|
const readline = require('node:readline');
|
|
|
|
const {stdin: input, stdout: output} = require('node:process');
|
|
|
|
const rl = readline.createInterface({input, output});
|
2022-08-19 09:36:34 +07:00
|
|
|
const config = require('./config');
|
2022-11-20 14:29:11 +07:00
|
|
|
const {loadPlugins} = require('./util/loadPlugins');
|
2022-11-14 17:45:49 +07:00
|
|
|
const {createBot} = require('./bot');
|
2022-08-14 16:51:45 +07:00
|
|
|
const {
|
|
|
|
Client,
|
|
|
|
Intents,
|
|
|
|
} = require('discord.js');
|
|
|
|
const intents = new Intents(['GUILDS', 'GUILD_MESSAGES']);
|
|
|
|
const dcclient = new Client({
|
|
|
|
intents,
|
|
|
|
});
|
|
|
|
|
2022-11-14 17:45:49 +07:00
|
|
|
const bots = [];
|
2022-08-14 16:51:45 +07:00
|
|
|
|
2022-11-14 17:45:49 +07:00
|
|
|
dcclient.on('ready', () => {
|
|
|
|
config.servers.forEach(async (server) => {
|
2022-11-15 18:30:35 +07:00
|
|
|
const getBots = () => bots;
|
|
|
|
// await is important cuz the function is async
|
|
|
|
// VVVVV
|
2022-11-20 14:29:11 +07:00
|
|
|
const bot = await createBot(server, config, getBots, dcclient, rl);
|
2022-11-15 18:30:35 +07:00
|
|
|
bots.push(bot);
|
2022-08-14 16:51:45 +07:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
dcclient.login(config.discord.token);
|
2022-11-20 19:19:10 +07:00
|
|
|
|
|
|
|
process.on('uncaughtException', (e) => {
|
|
|
|
console.log('uncaught ' + e);
|
|
|
|
});
|