Update 1.0.0
This commit is contained in:
39
events/client/interactionCreate.js
Normal file
39
events/client/interactionCreate.js
Normal file
@@ -0,0 +1,39 @@
|
||||
const {InteractionType} = require("discord.js")
|
||||
module.exports = {
|
||||
name: 'interactionCreate',
|
||||
|
||||
/**
|
||||
* @param {CommandInteraction} interaction
|
||||
* @param {Client} client
|
||||
*/
|
||||
async execute(interaction, client) {
|
||||
|
||||
if (interaction.type !== InteractionType.ApplicationCommand) return;
|
||||
|
||||
const command = client.slash.get(interaction.commandName);
|
||||
if (!command) return interaction.reply({ content: `Command doesn't exist!`, ephemeral: true });
|
||||
|
||||
if (command.ownerOnly) {
|
||||
if (interaction.user.id !== client.config.ownerID) {
|
||||
return interaction.reply({ content: `Permission Denied`, ephemeral: true });
|
||||
}
|
||||
}
|
||||
|
||||
const args = [];
|
||||
|
||||
for (let option of interaction.options.data) {
|
||||
if (option.type === 'SUB_COMMAND') {
|
||||
if (option.name) args.push(option.name);
|
||||
option.options?.forEach(x => {
|
||||
if (x.value) args.push(x.value);
|
||||
});
|
||||
} else if (option.value) args.push(option.value);
|
||||
}
|
||||
|
||||
try {
|
||||
command.run(client, interaction, args)
|
||||
} catch (e) {
|
||||
interaction.reply({ content: e.message });
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user