Autocomplete `interaction.commandName` when used in a subcommand

What will be the contents of interaction.commandName in an autocomplete interaction handler when the invoking interaction came from a subcommand or a subcommand in a group? Is it just baseCommand subCommand and baseCommand group subCommand? On a similar note, does interaction.commandId change for each subcommand?
Solution:
So is the commandName property on the interaction that gets passed into the interaction handler just the subcommand name then or is it the parents? At this point, you've said both.
Jump to solution
14 Replies
Sawako
Sawako•2y ago
All subcommands and command group inherit the id of the parent command
Ben
Ben•2y ago
That makes sense. What about the name?
Sawako
Sawako•2y ago
The parent command name
Ben
Ben•2y ago
So is there any way to differentiate between subcommands in the same command?
Sawako
Sawako•2y ago
With the name, since there can't be 2 subcommands with the same name Either in a group of commands or directly from the parent command
Ben
Ben•2y ago
So the name isn't the parent commands name?
Sawako
Sawako•2y ago
Well, each subcommand has its own name that you can get with .getSubcommand
Solution
Ben
Ben•2y ago
So is the commandName property on the interaction that gets passed into the interaction handler just the subcommand name then or is it the parents? At this point, you've said both.
Sawako
Sawako•2y ago
This property always carries the name of the invoked command, not the subcommands or group of subcommands since they inherit from the invoked command Sorry if I have confused you 😥
Ben
Ben•2y ago
Its all good. If I'm understanding correctly then, in order to determine which subcommand I'm in, I'd need to check interaction.options.getSubcommand().
Sawako
Sawako•2y ago
Yees
Ben
Ben•2y ago
Alright then. Thanks for the help!
Sawako
Sawako•2y ago
And to differentiate from a direct subcommand of the parent command to one of subcommands group that have the same name check if the subcommand has a subcommand HinataThumbsUp
Ben
Ben•2y ago
Yeah that makes sense. I'll probably write a quick util just to extract the full command path so I can check against that for ease of use.
Want results from more Discord servers?
Add your server