-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
33 lines (23 loc) · 917 Bytes
/
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
require('dotenv').config();
const Discord = require('discord.js');
const fs = require('fs');
const PREFIX = ".";
const client = new Discord.Client();
// load all commands
client.commands = new Discord.Collection();
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
client.commands.set(command.name, command);
}
client.once("ready", () => console.log("FOB Tracker Online"));
client.on("message", message => {
// check for message prefix
if (!message.content.startsWith(`${PREFIX}`) || message.author.bot) return;
// parse command and arguments
let args = message.content.trim().split(/ +/);
let command = args.shift().substr(1);
// run command
client.commands.get(command).execute(message, args)
})
client.login(process.env.BOT_TOKEN); //BOT_TOKEN is the Client Secret