Updated autocomplete event handler
Signed-off-by: Taken <taken@mairimashita.org>
This commit is contained in:
@@ -6,7 +6,6 @@ module.exports = {
|
||||
/** @param { import("discord.js").AutocompleteInteraction } interaction */
|
||||
|
||||
async execute(interaction) {
|
||||
if (!interaction.isAutocomplete()) return
|
||||
if (interaction.commandName !== "unban") return
|
||||
const focusedOption = interaction.options.getFocused(true)
|
||||
if (focusedOption.name !== "user") return
|
||||
|
||||
@@ -14,7 +14,19 @@ function loadAutocompleteEvents(client) {
|
||||
const autocomplete = require(filePath)
|
||||
|
||||
if ("name" in autocomplete && "execute" in autocomplete && autocomplete.type === "autocomplete") {
|
||||
client.on(Events.InteractionCreate, autocomplete.execute)
|
||||
client.on(Events.InteractionCreate, async interaction => {
|
||||
if (!interaction.isAutocomplete()) return
|
||||
|
||||
try {
|
||||
await autocomplete.execute(interaction)
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
await interaction.respond({
|
||||
content: "There was an error while executing this command!",
|
||||
ephemeral: true
|
||||
})
|
||||
}
|
||||
})
|
||||
} else {
|
||||
console.log(`[WARNING] The autocomplete at ${filePath} is missing a required "name", "execute" or "type" property.`)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user