how do you modularize your subcommands so their implementation is in different files?
can someone link me to a resource? https://discordjs.guide/slash-commands/advanced-creation.html#subcommands
i understand you can
.addSubcommand(<imported subcommand>.data)
but how should the subcommand file look like? is it still SlashCommandBuilder
or SlashCommandSubcommandBuilder
?9 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Not a discord.js issue? Check out #other-js-ts.
- Consider reading #how-to-get-help to improve your question!
- Explain what exactly your issue is.
- Post the full error stack trace, not just the top part!
- Show your code!
- Issue solved? Press the button! SlashCommandSubcommandBuilder (extends SharedNameAndDescription)
Represents a subcommand For more information, go to https://discord.com/developers/docs/interactions/application-commands#subcommands-and-subcommand-groups
let's say i just have
both
/command
and /command subcommand
show up. how do i hide the main command so just the latter shows up?
ty for the help and clarifications!
how do i make sure to prevent this?If you have duplicate commands on your server, you registered both global and guild commands.
You can remove the duplicates by resetting either the global or guild commands
- Resetting global commands:
rest.put(Routes.applicationCommands(clientId), { body: [] })
- Resetting guild commands: rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: [] })
i have that in my
deploy-commands.js
which i run everytime i start up the bot./brawl create
is running the main brawl command (which shouldn't be seen) and ./create
is my actual command and it works. is there a fix to removing ./create
but having ./brawl create
be the correct functionalityideally,
/brawl create
is the only thing that should be visable. i reset the global/guild commands using the guide's deploy-commands.js
is there something special you need to do with the command handler for subcommands?Unknown User•15mo ago
Message Not Public
Sign In & Join Server To View
everything works fine when i have it all in 1 file. somehow separating it is causing a problem
do you have an example of something i can reference? the only thing i have in my main slashcommand is
.addSubcommand(importedcmd.data, importedcmd.execute)
ahhh i failed to understand that ty
only ./brawl create
shows up. great! but the output is wrong bc it's executing the brawl.js
interaction reply (which shouldn't be seen)
do i have to change my slashcommand handler or is there something i can do inside brawl.js
from my understanding, my command handler is essentially the guide's https://discordjs.guide/creating-your-bot/command-handling.html#command-categories
await command.execute(interaction);
brawl.js
on discord the ./brawl create
shows with all of it's desc and options but when i run it, executes the reply you see above. any thoughts on how to change the interaction to execute my subcommands?
do i need to add my subcommands separately from the main commands?
do i need to explain more?
fixed it. have to .getSubcommand()
and invoke it in the main slashcommand execute