2022-11-27 02:35:28 -05:00
|
|
|
const readline = require('node:readline')
|
|
|
|
const { stdin: input, stdout: output } = require('node:process')
|
|
|
|
const rl = readline.createInterface({ input, output })
|
|
|
|
const config = require('./config')
|
|
|
|
const { createBot } = require('./bot')
|
2022-12-24 00:59:52 -05:00
|
|
|
const { Client, GatewayIntentBits } = require('discord.js')
|
|
|
|
const { MessageContent, GuildMessages, Guilds } = GatewayIntentBits
|
|
|
|
|
|
|
|
const dcclient = new Client({ intents: [Guilds, GuildMessages, MessageContent] })
|
2022-08-14 05:51:45 -04:00
|
|
|
|
2022-11-27 02:35:28 -05:00
|
|
|
let bots = []
|
2022-08-14 05:51:45 -04:00
|
|
|
|
2022-11-14 05:45:49 -05:00
|
|
|
dcclient.on('ready', () => {
|
2023-01-23 07:19:49 -05:00
|
|
|
for (const server of config.servers) {
|
2022-11-27 02:35:28 -05:00
|
|
|
const getBots = () => bots
|
2022-11-27 00:46:19 -05:00
|
|
|
const setNewBot = (server, bot) => {
|
2023-01-19 05:13:25 -05:00
|
|
|
bots = bots.filter((eachBot) => eachBot.server.host !== server)
|
2022-11-27 02:35:28 -05:00
|
|
|
bots.push(bot)
|
|
|
|
}
|
2022-12-30 04:20:12 -05:00
|
|
|
createBot(server, config, getBots, setNewBot, dcclient, rl)
|
2023-01-23 07:19:49 -05:00
|
|
|
}
|
2022-11-27 02:35:28 -05:00
|
|
|
})
|
2022-08-14 05:51:45 -04:00
|
|
|
|
2022-11-27 02:35:28 -05:00
|
|
|
dcclient.login(config.discord.token)
|
2022-11-20 07:19:10 -05:00
|
|
|
|
|
|
|
process.on('uncaughtException', (e) => {
|
2022-11-30 06:01:46 -05:00
|
|
|
console.log('uncaught ' + e.stack)
|
2022-11-27 02:35:28 -05:00
|
|
|
})
|