How to get subcommand name from interaction object?

I am will be having multiple commands which have their own sub commands (3 sub command per parent command). Out of those 3 sub commands, 2 of them will have AutoComplete. How do I distinguish between sub commands? interaction.commandName gives only the parent command name, not sub command name
Solution:
After some research I found out that this can be done using:
interaction.options.getSubcommand()
interaction.options.getSubcommand()
...
Jump to solution
4 Replies
Solution
MRDGH2821
MRDGH2821•2y ago
After some research I found out that this can be done using:
interaction.options.getSubcommand()
interaction.options.getSubcommand()
This gives the sub command name by which you can do respective operations
Favna
Favna•2y ago
You're correct. Should also note that this is DJS btw, not sapphire 🙂
MRDGH2821
MRDGH2821OP•2y ago
I realised this after finding out the solution 😅 For some reason, my autocomplete doesn't work, on which I'll do more research & maybe create appropriate thread
Favna
Favna•2y ago
Make sure that the option has autocomplete enabled in the registry and that it's a supported type. Also make sure the interaction handler is in the correct folder and such (interaction-handlers by default). And the handler has the correct type. Quite a few things to account for. It should all be covered in our guide. https://www.sapphirejs.dev/docs/Guide/interaction-handlers/autocomplete
Sapphire Framework
Autocomplete | Sapphire
Certain Chat Input Command options can be autocompleted based on what the user has written. There are two ways you can
Want results from more Discord servers?
Add your server