-
-
Notifications
You must be signed in to change notification settings - Fork 46
Open
Description
Hello, i am trying to implement slash commands in my project... But i am having problemas with the implemention.
I created the following function in utils/registry.ts
export async function registerSlashCommands(client: DiscordClient, commands: Collection<string, BaseCommand>) {
client.configs.forEach(async (guildConfig) => {
const guild = await client.guilds.fetch(guildConfig.guildId)
const applicationCommands = guild?.commands || client?.application?.commands
commands.map(cmd => {
applicationCommands?.create({ name: cmd.getName().toLowerCase(), description: cmd?.getDescription().toLowerCase() })
})
})
}And, i created the following interactionCreate event
client.on('interactionCreate', async interaction => {
if (!interaction.isCommand()) return;
if(!interaction.guildId) return;
const command = await client.commands.get(interaction.commandName)
if(!command) return;
try {
await command.execute(interaction);
} catch(e) {
if(e) console.log(e)
await interaction.reply({
content: 'An error ocurred while executing that command.',
ephemeral: true
})
}
})My problem is the function "execute" not exist, and i don't know how to fix it
await command.execute(interaction);What can i do to solve it?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels