-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathserver.js
More file actions
61 lines (42 loc) · 1.58 KB
/
server.js
File metadata and controls
61 lines (42 loc) · 1.58 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
const discord = require("discord.js")
const client = new discord.Client({ disableEveryone: true, disabledEvents: ["TYPING_START"] });
const { readdirSync } = require("fs");
const { join } = require("path");
const { TOKEN, PREFIX } = require("./config.json")
//CLIENT EVENTS
client.on("ready", () => {
console.log('Ready TO play some soft songs')
client.user.setActivity("x!help | Musix")
})
client.on("warn", info => console.log(info));
client.on("error", console.error)
//DEFINIING
client.commands = new discord.Collection()
client.prefix = PREFIX
client.queue = new Map();
//LETS LOAD ALL FILES
const cmdFiles = readdirSync(join(__dirname, "commands")).filter(file => file.endsWith(".js"))
for (const file of cmdFiles) {
const command = require(join(__dirname, "commands", file))
client.commands.set(command.name, command)
} //LOADING DONE
//WHEN SOMEONE MESSAGE
client.on("message", message => {
if (message.author.bot) return;
if (!message.guild) return;
if(message.content.startsWith(PREFIX)) { //IF MESSSAGE STARTS WITH MINE BOT PREFIX
const args = message.content.slice(PREFIX.length).trim().split(/ +/) //removing prefix from args
const command = args.shift().toLowerCase();
if(!client.commands.has(command)) {
return;
}
try { //TRY TO GET COMMAND AND EXECUTE
client.commands.get(command).execute(client, message, args)
} catch (err) { //IF IT CATCH ERROR
console.log(err)
message.reply("I am getting error on using this command")
}
}
});
//DONT DO ANYTHING WITH THIS TOKEN lol
client.login(TOKEN)