Search code examples
node.jsdiscord.js

Parallel execution of commands


CONTEXT For the few month, I've been writing a Discord Bot and everything was perfect but I have two problem: I have a command that take a long time to execute, any user that will request another command kill the current one and more and more user are using the bot, it's starting to be a bit difficult to run commands.

GOAL: Users should be able to execute any command at any time without having effect on the same/a different command summon by the same/a different user. To explain in a different way, bot shouldn't execute the last command received but more in a parallel way, like if every command executed was in a different instance.

For exemple, if two user in different server execute the same command at the same time, the bot must execute both in parallel so it can respond without delaying one of them or without cancelling one of them (current situation)

HOW: That's where I need you. I've heard of command handling but as far as I understand, it's not the answer

MOOD OF THE QUESTIONS*: Reddit | Stack Overflow
*They didn't answered my question but their question were not far from mine

CODE


Thank you for reading and have a nice day (or night) !

If I can improve this question by any way, let me know


Solution

  • A viable solution is to use command handling as described and explained by discordjs