Awaiting component interactions in Discord.js and optimization concerns when scaling up
Hey! I have a concern regarding awaiting components when serving a large amount of users.
I am building a bot that is a currency/banking system aimed at RPG guilds or any other that, well, needs a currency system that allows users to transfer to/trade with each other. One required step is to "open an account" with the "Bank" (bot). For that some setting up is required and, since I need select menus, buttons, and text inputs, I cannot simply use a modal.
In this multistep sign up process, awaiting components is perfect, since I only need one function that acts as a pipeline for the entire process.
However, my concern is: that function exists in the bot's process while it is awaiting. If my bot is awaiting a ton of users, how bad and how fast can it get?
EDIT: I know I can set a timeout, but even so...
What I've been doing before is split this functionality in several functions and, for every time the user interacts with a component, instead of await that component interaction I simply call the function for that specific interaction. User clicked on the "I agree", bot client receives the button interaction with
signup-btn-i-agree
and calls userClickedIAgreeShowThemOkMessage()
.
Can I await components even in large scale usage?
If my post is too confusing, please let me know and I'll rephrase or clarify whatever's not understandable.
Thanks in advance. Have a great weekend!3 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!I think a good step would be to look up how awaiting/promises/the js event loop works in general, it could give you a starting point to know what is actually going on when you await "a ton of users", and where you should change your code
in essence it doesn't just "wait" but rather like execute it in the background and come back to it later
there are other resources that can definitely explain better than me though lol
right, makes sense, i'll do some more digging
That's what I was looking for. Thank you for the insight!