Allow commands to use autocomplete
This commit is contained in:
@@ -8,9 +8,17 @@ const log = new DebugBuilder("server", "interactionCreate");
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
name: Events.InteractionCreate,
|
name: Events.InteractionCreate,
|
||||||
async execute(interaction) {
|
async execute(interaction) {
|
||||||
if (!interaction.isChatInputCommand()) return;
|
|
||||||
|
|
||||||
const command = interaction.client.commands.get(interaction.commandName);
|
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) {
|
if (!command) {
|
||||||
log.ERROR(`No command matching ${interaction.commandName} was found.`);
|
log.ERROR(`No command matching ${interaction.commandName} was found.`);
|
||||||
|
|||||||
Reference in New Issue
Block a user