-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbot.js
70 lines (45 loc) · 1.81 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
const { Client, Intents, Collection, MessageEmbed } = require('discord.js');
const discord = require("discord.js")
const client = new discord.Client({ disableEveryone: true });
const { readdirSync } = require("fs");
const { join } = require("path");
const config = require("./config.json");
client.on("ready", () => {
client.user.setActivity(config.PREFIX+" - " + client.users.cache.size + " user and " + client.guilds.cache.size + " server", { type: "STREAMING", url: "https://twitch.tv/rootcf" })
console.log('Online!');
});
client.on("warn", info => console.log(info));
client.on("error", console.error)
client.commands = new discord.Collection()
client.alias = new Collection()
client.prefix = config.PREFIX
client.queue = new Map();
const cmdFiles = readdirSync(join(__dirname, "commands")).filter(file => file.endsWith(".js"))
for (const file of cmdFiles) {
let pull = require(`./commands/${file}`);
console.log(`Loading Command -> ${pull.name}`);
const command = require(join(__dirname, "commands", file))
client.commands.set(command.name, command)
command.alias.forEach(alias => client.alias.set(alias, command))
}
client.on("message", async message => {
if (message.author.bot) return;
if (!message.guild) return;
if (message.content.startsWith(config.PREFIX)) {
const args = message.content.slice(config.PREFIX.length).trim().split(/ +/)
const command = args.shift().toLowerCase();
if (!client.commands.has(command) && !client.alias.has(command)) {
return;
}
try {
if (client.commands.has(command))
client.commands.get(command).execute(client, message, args)
else
client.alias.get(command).execute(client, message, args)
} catch (err) {
console.log(err)
message.reply("Something happened!")
}
}
});
client.login(config.TOKEN)