How to handle multiple slash commands simultaenously?
When multiple people run slash commands on my bot, it always makes the commands fail until the current process is completed. How do I make it so people can use multiple commands at the same time?
31 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!discord.js 18
you must be in the future because latest version is v14
this is only your code for deploying commands
the relevant code would be the one that handles it
oh one sec
v20.16.0
are you sure the latest version is 14?
Unknown User•4w ago
Message Not Public
Sign In & Join Server To View
that's your node version
not your djs version
correct
your node version isn't the same as your djs version
you're in v14 then
what about this
here's another one also
when someone runs /xbox and someone runs /profile, the bot doesn't show both, it only shows xbox once it's loaded in.
Seems like it can't handle multiple commands at a time. Same goes for slash commands that do other things.
For example, this one
I can't run this while someone in the server has used another slash command.
I have to wait for the command to fully process before I can run it. Otherwise, it times out. No console errors though, so i'm confused.
what about the code that listens to interactionCreate and routes interactions to your commands?
what is your
pool
variable?
because my first thought is that your db is the one blocking you
here's the full bot.js file
check this
Ohhh
If you don't release the client your application will leak them and eventually your pool will be empty forever and all future requests to check out a client from the pool will wait forever.
So that's why it's not working.though it looks like you use pool.query() directly
not a client from it
Hmm, so if I follow the instructions in that link, it will allow simultaenous commands?
it confused me because your parameters are called dbClient but they're actually a pool
now I'm not sure if you're affected by that
why do you make another pool here though?
aren't I supposed to?
you're supossed to only have one pool
the whole purpose of the pool is to be re-used so it can manage clients efficiently across all the program's objects that need access to the db
Ah I see, that's good to know.
How am I doing so far otherwise?
total bot has 55,000 lines of code, spent 3 months, 12 hours+ a day
Myself and 2 other devs worked on it.
tbh it doesn't look like a djs issue, and I'm not quite sure what the problem could be
when you use the command while another one is "in progress", does it at least defer?
it may be from your database, i had these problems too when i was using mongodb and my bot was handling a lot of commands per second from users
i hope not, postgre gives me a headache
no, it just says "this interaction has failed"