How to call Slash commands in another slash command?
Hi! We are making a discord bot as a school project and our goal is to have a /creategroup command that uses already made commands as
/createroom
/createrole
/createcategory
For example our create room currently looks like this :
https://pastebin.com/VqKPtmiK
And we are trying to call it like this
https://pastebin.com/beEfLwsf
But we are currently running into a problem setting the Name for the room we are trying to create.
the error is something like :
"DiscordAPIError[50035]: Invalid Form Body"
"name[BASE_TYPE_REQUIRED]: this field is required"
Ideal functionality would be
When /creategroup is called
it creates a channel using the /createchannel command with the given option
and creates channels specified with the given name "groupname"general for example.
Is our creategroup command doomed to fail in the first place? Or how we should handle sending the option for the latter command.
Pastebin
createroom - Pastebin.com
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Pastebin
creategroup - Pastebin.com
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
6 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!
- ✅
Marked as resolved by OPbots cannot execute their own or other bots' slash commands
as for your error, show the full stack
https://pastebin.com/PB1e6FCF Here is the index.js. The git repo is handled by our school and can't be linked to outside viewing so cant really share the whole stack.
Pastebin
index.js - Pastebin.com
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
So just to clarify this following scenario isn't possible?
/creategroup is used with option "testname123"
inside the creategroup.js file is a call to the execute function of our createroom command and the option is passed onto it
and then the excecute function is ran .
its kinda hard to debug without having the full stack
why not just all creation in 1 file?
because assuming your other commands can be used as standalone commansd that will error
seen you already reply to the interaction and probably reply again in the command
The reason we are doing this as a fragmented is we all had 0 experience with either discord bots or js in general and just started to build smaller commands with the intention to later use them as the 1 creategroup command
but if it's impossible then ye we will just make it a 1 file that handles the creation process. Just thought it would be simpler.
After a quick try this seems to be the way we want to take. Thank you for help :)