Split command
Hello, I'm asking for help because I don't even know how to implement this
I have 2 commands /creative work and /creative action
Keeping them in one file is very inconvenient, and I want to split them into two (something like work.js and action.js)
But here's the problem: when I split it into different files, I get an error
As I understand it, he swears specifically at /creative
So the question is, what needs to be changed in commandHandler and/or deploy so that I can use /creative in different files?
CommandHandler code:
deploy.js code:
Thanks in advance for helping a newbie!
4 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 OPcan you show how did you separate this two commands
show the scripts
work.js
action.js
yea i had a feeling
ideally you would have an "entry" file for this command, in which you define its data (the builder) and use that file to deploy to the api, then inside that, lets call it "mini handler", you branch into the other subcommands, for example, with a switch statement
const subcommand = interaction.options.getSubcommand()
switch (subcommand) { case "test": TestCommandHandler(interaction); break; }
if you plan on adding more and more commands this can get messy, you can go around that in other ways but for now this is just an idea
right now your issue is that you are trying to deploy both commands as separate commands and both define the main one as "creative"