-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
53 lines (37 loc) · 1.26 KB
/
index.js
File metadata and controls
53 lines (37 loc) · 1.26 KB
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
45
46
47
48
49
50
51
52
53
const config = require('./botconfig.json');
const Discord = require('discord.js');
const fs = require("fs");
const bot = new Discord.Client({disableEveryone: true});
bot.commands = new Discord.Collection();
fs.readdir("./commands", (err, files) => {
if(err) console.log(err);
let jsfile = files.filter(f => f.split(".").pop() === "js")
if(jsfile.length <= 0)
{
console.log("Couldn't find any commands");
return;
}
jsfile.forEach((f, i) => {
let props = require(`./commands/${f}`);
bot.commands.set(props.help.triggers, props);
});
});
// Create an instance of a Discord client
bot.on("ready", async () => {
console.log(`${bot.user.username} is now online!`);
bot.user.setActivity('G4G Development');
});
bot.on("message", async message => {
if(message.author.bot) return;
if(message.channel.type == "dm") return;
let prefix = config.prefix;
let messageArray = message.content.split(" ");
let command = messageArray[0];
let args = messageArray.slice(1); //takes the first item off the list aka the command
let commandfile = bot.commands.get(command.slice(prefix.length));
if(commandfile)
{
commandfile.run(bot, message, args);
}
});
bot.login(config.token);