Command, Subcommand and Subcommand goup
hi want to make a small suggestion about all these different command in discord
at the moment there is no use for Subcommand and Subcommand goup.
i would think i would have a better utility if it worked as “folder” for example if a have a “ai” module and decided to create 5 command if i use command i would have 5 command but if a use a “Subcommand ” i would need to click on the subcommand to see everything that are “inside” this subcommand and the same goes for subcommand group but i could store subcommand(subfolder) and command directly and not only one of the two like what are actually implemented.
I would also like to have control on the permission and “nsfw” of a command inside a subcommand or subcommand group since i use them for orginisation at the moment if 1 module have some nsfw and some sfw command i need to have 2 subcommand.
this would also impact client but in a lesser way than the api
-
Adaf3a
0 -
Hello, valgul
To organize Discord commands using subcommands and subcommand groups:
Create Subcommands:
JavaScriptconst command = new SlashCommandBuilder()
.setName('ai')
.setDescription('AI module commands')
.addSubcommand(subcommand => subcommand.setName('command1').setDescription('Description for command1'))
.addSubcommand(subcommand => subcommand.setName('command2').setDescription('Description for command2'));
Check Permissions:
JavaScriptclient.on('interactionCreate', async interaction => {
if (!interaction.isCommand()) return;
const { commandName, options } = interaction;
if (commandName === 'ai') {
const subcommand = options.getSubcommand();
if (subcommand === 'command1' && !interaction.member.permissions.has('ADMINISTRATOR')) {
return interaction.reply('You do not have permission to use this command.');
}
// Handle subcommands here
}
});This keeps your commands organized and allows for permission checks.
Best Regard,
Gregory Chavez
DollarTreeCompass0
Please sign in to leave a comment.
Comments
2 comments