mirror of
https://github.com/ChomeNS/chomens-bot-mc.git
synced 2024-11-30 02:55:44 -05:00
34 lines
917 B
JavaScript
34 lines
917 B
JavaScript
/* eslint-disable max-len */
|
|
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')
|
|
const {
|
|
Client,
|
|
Intents
|
|
} = require('discord.js')
|
|
const intents = new Intents(['GUILDS', 'GUILD_MESSAGES'])
|
|
const dcclient = new Client({
|
|
intents
|
|
})
|
|
|
|
let bots = []
|
|
|
|
dcclient.on('ready', () => {
|
|
config.servers.forEach(async (server) => {
|
|
const getBots = () => bots
|
|
const setNewBot = (server, bot) => {
|
|
bots = bots.filter((eachBot) => eachBot !== server)
|
|
bots.push(bot)
|
|
}
|
|
// await is important cuz the function is async
|
|
await createBot(server, config, getBots, setNewBot, dcclient, rl)
|
|
})
|
|
})
|
|
|
|
dcclient.login(config.discord.token)
|
|
|
|
process.on('uncaughtException', (e) => {
|
|
console.log('uncaught ' + e.stack)
|
|
})
|