-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.js
More file actions
35 lines (25 loc) · 885 Bytes
/
bot.js
File metadata and controls
35 lines (25 loc) · 885 Bytes
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
const Discord = require('discord.js');
const Enmap = require('enmap');
const fs = require('fs');
const client = new Discord.Client();
const prefix = '!bus';
client.commands = {};
client.notifications = new Enmap();
fs.readdirSync('commands').forEach(command => {
const cmd = require(`./commands/${command}`);
const cmdName = command.split('.')[0];
client.commands[cmdName] = cmd;
});
client.on('message', message => {
if (message.author.bot) return;
if (!message.guild) return;
if (message.content.indexOf(prefix) !== 0) return;
const args = message.content.slice(prefix.length).trim().split(/ +/g);
const command = args.shift().toLowerCase();
const cmd = client.commands[command];
if (!cmd) return;
cmd(client, message, args);
});
client.login(process.env.TOKEN)
.then(() => console.log('Bot Up!'))
.catch(console.error);