command-handling: index.js vs deploy-commands.js #1017
-
I am new to creating Discord bots and I am trying to understand the reason we need deploy-commands.js. I know this file pushes commands to our bot, but in the index.js file between lines 7 and 13 aren't we importing our commands to the bot? Why do we need to push commands to the bot using deploy-commands.js? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
deploy-commands.js registers the commands, it sends an api request to register whereas in index.js if you've followed the guide, it just reads your local files and stores them in a collection for future use these two are very different and the reason why we don't register in index.js and use a separate script is to separate the register process from the bot process, think about it, if we were to register using index.js, the file that gets ran every time the bot turns on, we'd be sending needless api requests to register the commands that haven't even changed |
Beta Was this translation helpful? Give feedback.
deploy-commands.js registers the commands, it sends an api request to register whereas in index.js if you've followed the guide, it just reads your local files and stores them in a collection for future use
these two are very different and the reason why we don't register in index.js and use a separate script is to separate the register process from the bot process, think about it, if we were to register using index.js, the file that gets ran every time the bot turns on, we'd be sending needless api requests to register the commands that haven't even changed
to avoid that and to make sure that you only send the request when you have changes and want to update the commands, the deploy-comm…