add event to handle incoming interaction creation events
every fired slash command is actually an event which needs to be handled and deferred to the correct command interaction handler.
This commit is contained in:
parent
4917fe11da
commit
2a03cd7589
|
@ -0,0 +1,21 @@
|
||||||
|
import { CommandInteractionOptionResolver } from "discord.js"
|
||||||
|
import { ExtendedInteraction } from "../types/commandTypes"
|
||||||
|
import { client } from "../.."
|
||||||
|
import { logger } from "../logger"
|
||||||
|
|
||||||
|
export const name = 'interactionCreate'
|
||||||
|
export async function execute(interaction: ExtendedInteraction) {
|
||||||
|
//console.dir(interaction, { depth: null })
|
||||||
|
if (interaction.isCommand()) {
|
||||||
|
logger.info(`Interaction is a command.`, { guildId: interaction.guild?.id })
|
||||||
|
await interaction.deferReply()
|
||||||
|
const command = client.commands.get(interaction.commandName)
|
||||||
|
if (!command)
|
||||||
|
return interaction.followUp('Invalid command')
|
||||||
|
command.run({
|
||||||
|
args: interaction.options as CommandInteractionOptionResolver,
|
||||||
|
client,
|
||||||
|
interaction
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue