slash commands integrated
* sample env and late version incr * added slash command compatibility * updated command name * updated environment sample * updated interaction comment
This commit is contained in:
19
src/events/interactionCreate.ts
Normal file
19
src/events/interactionCreate.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { event, Events } from '../utils/index.js'
|
||||
import commands from '../commands/index.js'
|
||||
|
||||
/**
|
||||
* Interaction creation listener for the client
|
||||
* @param interaction the interaction received from the server
|
||||
*/
|
||||
export default event(Events.InteractionCreate, async ({ log, client }, interaction) => {
|
||||
if (!interaction.isCommand() || !interaction.isChatInputCommand()) return
|
||||
|
||||
log(`Interaction called \'${interaction.commandName}\' from ${interaction.client.user.tag}.`)
|
||||
|
||||
// ensure command exists, otherwise kill event
|
||||
const command = commands.find(command => command.name === interaction.commandName)
|
||||
if (!command) return
|
||||
|
||||
// the command exists, execute it
|
||||
command.run(client, interaction)
|
||||
})
|
||||
Reference in New Issue
Block a user