-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.js
43 lines (34 loc) · 1.24 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
38
39
40
41
42
43
const Discord = require('discord.js');
const fs = require('promise-fs');
const async = require('async');
const config = require('./config.json')
const client = new Discord.Client();
require('dotenv').config()
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
});
function delete_message(msg) {
msg.delete(config.delete_timeout);
}
//https://gist.github.com/eslachance/3349734a98d30011bb202f47342601d3
client.on('message', async msg => {
if (msg.content.match(/.*c.*h.*r.*i.*s.*/i) !== null) {
const chris = client.emojis.find(emoji => emoji.name === 'Chris');
msg.react(chris.id);
}
if (msg.content.indexOf(config.prefix) !== 0) return;
const args = msg.content.slice(config.prefix.length).trim().split(/ +/g);
const cmd = args.shift().toLowerCase();
// TODO: return latency
// TODO: wrap commands with delete and delete_message
if (cmd === 'ping') {
msg.delete(config.delete_timeout);
msg.reply('pong').then(delete_message);
}
if (cmd === 'playlists') {
msg.delete(config.delete_timeout);
playlists = await fs.readdir('./playlists/');
msg.channel.send(playlists).then(delete_message);
}
});
client.login(process.env.botToken);