Skip to content

Instantly share code, notes, and snippets.

@AlexzanderFlores
Created September 10, 2022 16:24
Show Gist options
  • Save AlexzanderFlores/0a9bf11cbb86f019e1674001dc0202f8 to your computer and use it in GitHub Desktop.
Save AlexzanderFlores/0a9bf11cbb86f019e1674001dc0202f8 to your computer and use it in GitHub Desktop.
Autocomplete support example
// This is written in JS but the handler will still have TS support as expected
const {
PermissionFlagsBits,
ApplicationCommandOptionType,
} = require('discord.js')
module.exports = {
description: 'Toggles a command on or off for your guild',
type: 'SLASH',
guildOnly: true,
testOnly: true,
permissions: [PermissionFlagsBits.Administrator],
options: [
{
name: 'command',
description: 'The command to toggle on or off',
type: ApplicationCommandOptionType.String,
required: true,
autocomplete: true,
},
],
autocomplete: (interaction, command, arg) => {
// Return all of the registered commands
return [...command.instance.commandHandler.commands.keys()]
},
callback: async ({ instance, guild, text: commandName, interaction }) => {
// TODO: Toggle the command
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment