-
-
Save AlexzanderFlores/0a9bf11cbb86f019e1674001dc0202f8 to your computer and use it in GitHub Desktop.
Autocomplete support example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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