Skip to content

Commit 57a4889

Browse files
committed
Update events to new handler
1 parent 7564cd8 commit 57a4889

File tree

6 files changed

+80
-56
lines changed

6 files changed

+80
-56
lines changed

events/client/interactionCreate.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
module.exports = {
2+
name: 'interactionCreate',
3+
4+
/**
5+
* @param {CommandInteraction} interaction
6+
* @param {Client} client
7+
*/
8+
execute(interaction, client) {
9+
if (!interaction.isCommand()) return;
10+
11+
const command = client.slash.get(interaction.commandName);
12+
if (!command) return interaction.reply({ content: 'an Error' });
13+
14+
if (command.ownerOnly) {
15+
if (interaction.user.id !== client.config.ownerID) {
16+
return interaction.reply({ content: "This command only for Bot Owner!", epephemeral: true });
17+
}
18+
}
19+
20+
const args = [];
21+
22+
for (let option of interaction.options.data) {
23+
if (option.type === 'SUB_COMMAND') {
24+
if (option.name) args.push(option.name);
25+
option.options?.forEach(x => {
26+
if (x.value) args.push(x.value);
27+
});
28+
} else if (option.value) args.push(option.value);
29+
}
30+
31+
try {
32+
command.run(client, interaction, args)
33+
} catch (e) {
34+
interaction.reply({ content: e.message });
35+
}
36+
}
37+
}

events/client/messageCreate.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
module.exports = {
2+
name: 'messageCreate',
3+
4+
/**
5+
* @param {Message} message
6+
* @param {Client} client
7+
*/
8+
execute(message, client) {
9+
if (message.author.bot || !message.guild || !message.content.toLowerCase().startsWith(client.config.prefix)) return;
10+
11+
const [cmd, ...args] = message.content.slice(client.config.botPrefix.length).trim().split(" ");
12+
13+
const command = client.commands.get(cmd.toLowerCase()) || client.commands.find(c => c.aliases?.includes(cmd.toLowerCase()));
14+
15+
if (!command) return;
16+
17+
if (command.ownerOnly) {
18+
if (message.author.id !== client.config.ownerID) {
19+
return message.reply({ content: "This command only for Bot Owner!", allowedMentions: { repliedUser: false } });
20+
}
21+
}
22+
23+
await command.run(client, message, args);
24+
}
25+
}

events/client/ready.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module.exports = {
2+
name: 'ready',
3+
once: true,
4+
5+
/**
6+
* @param {Client} client
7+
*/
8+
execute(client) {
9+
// Puts an activity
10+
client.user.setActivity("Expectatives#1157", {
11+
type: "WATCHING",
12+
name: "Expectatives#1157"
13+
});
14+
15+
// Send a message on the console
16+
console.log(`[LOG] ${client.user.tag} is now online!\n[LOG] Bot serving on Ready to serve in ${client.guilds.cache.size} servers\n[LOG] Bot serving ${client.users.cache.size} users`);
17+
}
18+
}

events/interactionCreate.js

Lines changed: 0 additions & 25 deletions
This file was deleted.

events/messageCreate.js

Lines changed: 0 additions & 17 deletions
This file was deleted.

events/ready.js

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)