Allow commands to use autocomplete

This commit is contained in:
Logan Cusano
2023-06-03 23:31:27 -04:00
parent 7d8ad68e27
commit 8ab611836b

View File

@@ -8,9 +8,17 @@ const log = new DebugBuilder("server", "interactionCreate");
module.exports = {
name: Events.InteractionCreate,
async execute(interaction) {
if (!interaction.isChatInputCommand()) return;
const command = interaction.client.commands.get(interaction.commandName);
log.VERBOSE("Interaction for command: ", command);
// Execute autocomplete if the user is checking autocomplete
if (interaction.isAutocomplete()) {
log.DEBUG("Running autocomplete for command: ", command.data.name);
return await command.autocomplete(interaction);
}
// Check if the interaction is a command
if (!interaction.isChatInputCommand()) return;
if (!command) {
log.ERROR(`No command matching ${interaction.commandName} was found.`);