2022-11-27 00:46:19 -05:00
|
|
|
/* eslint-disable max-len */
|
2022-11-20 01:00:00 -05:00
|
|
|
const readline = require('node:readline');
|
|
|
|
const {stdin: input, stdout: output} = require('node:process');
|
|
|
|
const rl = readline.createInterface({input, output});
|
2022-08-18 22:36:34 -04:00
|
|
|
const config = require('./config');
|
2022-11-14 05:45:49 -05:00
|
|
|
const {createBot} = require('./bot');
|
2022-08-14 05:51:45 -04:00
|
|
|
const {
|
|
|
|
Client,
|
|
|
|
Intents,
|
|
|
|
} = require('discord.js');
|
|
|
|
const intents = new Intents(['GUILDS', 'GUILD_MESSAGES']);
|
|
|
|
const dcclient = new Client({
|
|
|
|
intents,
|
|
|
|
});
|
|
|
|
|
2022-11-27 00:46:19 -05:00
|
|
|
let bots = [];
|
2022-08-14 05:51:45 -04:00
|
|
|
|
2022-11-14 05:45:49 -05:00
|
|
|
dcclient.on('ready', () => {
|
|
|
|
config.servers.forEach(async (server) => {
|
2022-11-15 06:30:35 -05:00
|
|
|
const getBots = () => bots;
|
2022-11-27 00:46:19 -05:00
|
|
|
const setNewBot = (server, bot) => {
|
|
|
|
bots = bots.filter((eachBot) => eachBot !== server);
|
|
|
|
bots.push(bot);
|
|
|
|
};
|
2022-11-15 06:30:35 -05:00
|
|
|
// await is important cuz the function is async
|
|
|
|
// VVVVV
|
2022-11-27 00:46:19 -05:00
|
|
|
const bot = await createBot(server, config, getBots, setNewBot, dcclient, rl);
|
2022-11-15 06:30:35 -05:00
|
|
|
bots.push(bot);
|
2022-08-14 05:51:45 -04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
dcclient.login(config.discord.token);
|
2022-11-20 07:19:10 -05:00
|
|
|
|
|
|
|
process.on('uncaughtException', (e) => {
|
|
|
|
console.log('uncaught ' + e);
|
|
|
|
});
|