-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.js
37 lines (31 loc) · 1.08 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
const Discord = require('discord.js');
const statTools = require('./StatTools');
const table = require('./MakeTable');
// set bot token
const token = '';
// create a new Discord client
const client = new Discord.Client();
// set command prefix
const prefix = '!';
var file_path = '';
client.on('message', (msg) => {
// look for command messages only
if (!msg.content.startsWith(prefix) || msg.author.bot) {
return;
}
// get bot command and command argument
const args = msg.content.slice(prefix.length).split(' ');
const command = args.shift().toLowerCase();
// command for user to set replay directory
if (command === 'path') {
file_path = msg.content.substring(6);
msg.channel.send(`Path set to ${file_path}`);
}
// command for user to generate table of latest replay
if (command === 'stats') {
const replay = statTools.findLatestReplay(file_path);
msg.channel.send(table.makeTable(replay, file_path));
}
});
// login to Discord with your app's token
client.login(token);