-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
61 lines (32 loc) · 1.28 KB
/
index.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
const Discord = require("discord.js");
const { Client, Intents, MessageEmbed } = require("discord.js");
const client = new Client({
intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES],
disableEveryone: true,
});
const config = require("./settings.json");
client.once("ready", () => {
console.log(`Logged as ${client.user.tag}!`);
client.user.setPresence({
activities: [{ name: `!help`, type: `LISTENING` }]
});
});
// command sender setup
const fs = require("fs");
client.commands = new Discord.Collection();
const commandFiles = fs.readdirSync('./commands/').filter(file => file.endsWith('.js'));
for(const file of commandFiles){
const command = require(`./commands/${file}`);
console.log(`Loading command: ${command.name}`);
client.commands.set(command.name, command);
}
// command sending
client.on("message", message => {
if(!message.content.startsWith(config.prefix) || message.author.bot) return;
const args = message.content.slice(config.prefix.length).split(/ +/);
const command = args.shift().toLowerCase();
client.commands.get(command).execute(message, args);
});
client.login(config.token).catch(err => {
console.log("Error: " + err);
})