Création Repo pour mon bot Le Tamiseur
This commit is contained in:
34
events/interactionCreate.js
Executable file
34
events/interactionCreate.js
Executable file
@@ -0,0 +1,34 @@
|
||||
const { Events } = require('discord.js')
|
||||
|
||||
module.exports = {
|
||||
name: Events.InteractionCreate,
|
||||
async execute(interaction) {
|
||||
if (interaction.isButton()) {
|
||||
let button = interaction.client.buttons.get(interaction.customId)
|
||||
if (!button) return console.error(`No button id matching ${interaction.customId} was found.`)
|
||||
|
||||
console.log(`\u001b[1;33m Button '${interaction.customId}' clicked by ${interaction.user.tag}`)
|
||||
|
||||
try { await button.execute(interaction) }
|
||||
catch (error) { console.error(`Error executing ${interaction.customId}:`, error) }
|
||||
}
|
||||
|
||||
if (!interaction.isAutocomplete() && !interaction.isChatInputCommand()) return //console.error(`Interaction ${interaction.commandName} is not a command.`)
|
||||
|
||||
let command = interaction.client.commands.get(interaction.commandName)
|
||||
if (!command) return console.error(`No command matching ${interaction.commandName} was found.`)
|
||||
|
||||
if (interaction.isAutocomplete()) {
|
||||
console.log(`\u001b[1;33m AutoCompleteRun '${interaction.commandName}' launched by ${interaction.user.tag}`)
|
||||
|
||||
try { await command.autocompleteRun(interaction) }
|
||||
catch (error) { console.error(`Error autocompleting ${interaction.commandName}:`, error) }
|
||||
}
|
||||
else if (interaction.isChatInputCommand()) {
|
||||
console.log(`\u001b[1;33m Command '${interaction.commandName}' launched by ${interaction.user.tag}`)
|
||||
|
||||
try { await command.execute(interaction) }
|
||||
catch (error) { console.error(`Error executing ${interaction.commandName}:`, error) }
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user