-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
39 lines (28 loc) · 1.13 KB
/
index.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
const botconfig = require("./configs/botconfig.json");
const Discord = require("discord.js");
const bot = new Discord.Client();
const fs = require("fs");
const cmdHandler = require("./utils/commandHandler.js");
const eventHandler = require("./utils/eventHandler.js");
bot.commands = new Discord.Collection();
bot.events = new Discord.Collection();
bot.aliases = new Discord.Collection();
cmdHandler.run(bot,"./commands/")
eventHandler.run(bot,"./events/")
bot.on("message", async message => {
if (message.channel.type === 'dm' || message.author.bot){
return;
}
let prefix = botconfig.prefix;
let args = message.content.slice(prefix.length).trim().split(` `)
let cmd = args.shift().toLowerCase()
let commandfile
if(!message.content.startsWith(prefix)) return;
if(bot.commands.has(cmd)){
commandfile = bot.commands.get(cmd)
}else{
commandfile = bot.commands.get(bot.aliases.get(cmd))
}
if(commandfile) commandfile.run(bot,message,args,prefix);
});
bot.login(botconfig.token);