-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathindex.js
33 lines (23 loc) · 1.1 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
const { Discord, Client, Partials, GatewayIntentBits } = require('discord.js');
const client = new Client({
partials: [Partials.Message, Partials.Channel, Partials.Reaction],
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.GuildMembers],
});
const { loadCommands } = require('./utils/loadCommands');
client.login("BOT_TOKEN");
client.commands = new Discord.Collection();
client.aliases = new Discord.Collection();
loadCommands(client);
client.on('ready', bot => {
console.log(`[BOT] Logged in as ${client.user.username}#${client.user.discriminator}.`)
});
client.on('messageCreate', message => {
if (message.author.bot) return;
const messageArray = message.content.split(/\s+/); // This regex splits on every whitespace
const cmd = messageArray[0];
const args = messageArray.slice(1);
const prefix = "!";
if (!message.content.startsWith(prefix)) return;
const commandfile = client.commands.get(cmd.slice(prefix.length)) || bot.commands.get(bot.aliases.get(cmd.slice(prefix.length)));
commandfile.run(client, message, args);
});