knightrider/src/applications/bot.js
2021-08-25 01:01:46 +01:00

22 lines
No EOL
708 B
JavaScript

/*
* licence https://github.com/404invalid-user/knightrider/blob/main/LICENCE
*/
const chalk = require('chalk')
const { readdirSync } = require('fs')
const Discord = require('discord.js')
module.exports = (client, webServer) => {
client.commands = new Discord.Collection();
client.addons = [];
const handlers = readdirSync(__dirname + '/../bot/handlers/').filter((file) => file.endsWith(".js"));
for (let handler of handlers) {
require(`../bot/handlers/${handler}`)(client);
}
try {
client.login(require('../conf/tokens').bot.token);
} catch (error) {
console.log(chalk.blue('[bot]: ') + chalk.red('(error): ') + "cant login error: " + error);
}
}