-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
64 lines (51 loc) · 2.1 KB
/
index.js
File metadata and controls
64 lines (51 loc) · 2.1 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
61
62
63
64
//declare requirements
const Discord = require("discord.js");
const fs = require('fs');
const config = require("./config.json");
var prefix = config.PREFIX;
// declare new discord client
const client = new Discord.Client();
client.commands = new Discord.Collection();
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
var str = "./commands/"+file;
console.log(str)
const command = require(str);
client.commands.set(command.name, command);
}
//read each message in server
client.on("message", function (message) {
if (message.author.bot) return;
if (!message.content.startsWith(prefix)) return;// read if message start with prefix
const args = message.content.slice(prefix.length).trim().split(/ +/g);
const command = args.shift().toLowerCase();
/*
============================================================================
COMMANDS
============================================================================
*/
//------------------------------------------------------------------------------> User avatar
if (command.toLowerCase() === "avatar") {
const avatar = new Discord.MessageAttachment(message.author.displayAvatarURL());
message.channel.send(avatar);
}
else if(command.toLowerCase() === "help"){
client.commands.get('help').execute(message, command);
}
else if(command.toLowerCase() === "skill" || command.toLowerCase() === "s"){
client.commands.get('helpSkills').execute(message, args);
}
else if(command.toLowerCase() === "combatinfo"){
client.commands.get('combatinfo').execute(message, command);
}
else if(command.toLowerCase() === "linkstart"){
client.commands.get('linkstart').execute(message, command);
}
else if(command.toLowerCase() === "profile"){
client.commands.get('profile').execute(message, command);
}
else if(command.toLowerCase() === "combat"){
client.commands.get('combat').execute(message, command);
}
});
client.login(config.BOT_TOKEN);