-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbot.js
44 lines (37 loc) · 1.12 KB
/
bot.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Import Eris, winston for logging, and require-dir to get commands later
const Eris = require('eris');
const winston = require('winston');
const requireDir = require('require-dir');
// Import configs
const config = require('./config.json');
// Initialize client
const bot = new Eris.CommandClient(config.self_token, {}, {
ignoreSelf: false,
description: 'An Eris-based Discord self bot with simple, useful commands',
name: config.bot_name,
owner: config.owner_name,
prefix: config.prefix,
defaultHelpCommand: false,
defaultCommandOptions: {
caseInsensitive: true,
requirements: {
userIDs: [
config.user_id,
],
},
},
});
// Import commands
const commands = requireDir('./commands');
// Set some configs as bot prop
bot.selfConfig = {
msgTimeout: config.msg_timeout,
errorColor: config.error_color,
successColor: config.success_color,
};
// Register commands
Object.values(commands).forEach(command => command(bot));
// Discord login
bot.connect();
// Ready event
bot.on('ready', () => winston.info(`Connected with ${bot.guilds.size} guilds and ${Object.keys(commands).length} commands`));