chomens-bot-js/index.js
ChomeNS 508b6a64c7 idk just use for loop and not forEach
i see its faster so i use it
2023-01-23 19:19:49 +07:00

28 lines
893 B
JavaScript

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, GatewayIntentBits } = require('discord.js')
const { MessageContent, GuildMessages, Guilds } = GatewayIntentBits
const dcclient = new Client({ intents: [Guilds, GuildMessages, MessageContent] })
let bots = []
dcclient.on('ready', () => {
for (const server of config.servers) {
const getBots = () => bots
const setNewBot = (server, bot) => {
bots = bots.filter((eachBot) => eachBot.server.host !== server)
bots.push(bot)
}
createBot(server, config, getBots, setNewBot, dcclient, rl)
}
})
dcclient.login(config.discord.token)
process.on('uncaughtException', (e) => {
console.log('uncaught ' + e.stack)
})