-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.js
More file actions
60 lines (49 loc) · 1.69 KB
/
bot.js
File metadata and controls
60 lines (49 loc) · 1.69 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
54
55
56
57
58
59
60
//Packages and dependencies
const Discord = require('discord.js');
const fs = require('fs');
//Instances
const client = new Discord.Client();
const auth = require('./auth.json');
client.commands = new Discord.Collection();
//Gets all command names by the name of their file
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
//Gets all the names of the sfxs
const sfxFiles = fs.readdirSync('./soundEffects').filter(file => file.endsWith('.mp3'));
//Retrieves all commands
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
client.commands.set(command.name, command);
}
//Ready
client.once('ready', () => {
client.user.setActivity(" BITCONNEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEECT!");
});
/****************** Basic functions ******************************/
//reconnect
client.once('reconnecting', () => {
console.log('Reconnecting!');
});
//Disconnect
client.once('disconnect', () => {
console.log('Disconnect!');
});
/*************************** Dinamic Commands ************************/
client.on('message', message => {
var args = message.content.slice(auth.prefix.length).split(/ +/);
var command = args.shift();
if (!message.content.startsWith(auth.prefix) || !client.commands.has(command)) return;
else {
try {
client.commands.get(command).execute(message, args, sfxFiles, function(data){
if(data != null){
sfxFiles.push(data);
}
});
} catch (error) {
console.error(error);
message.reply('there was an error trying to execute that command!');
}
}
});
//Login
client.login(auth.token);