Get around deferReply's lag
i'm trying to get around the lag caused by awaiting message.deferReply constantly, i'd like to do message.deferReply without awaiting it, but that causes issues when replying to it: if i do editReply or followUp, then it'll break if the bot tries to reply before the deferReply completes
what's the solution to get around this?
12 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!get a better host / network
usually deferreply should not lag a ton
it doesn't, but trying to optimize performance, and removing awaits helps with that
but fair enough, guess there's no way to get around it?
you should not remove awaits
they will break stuff
yeah, blindly removing awaits is bad since it can cause problems like the one described above, trying to figure out if this one is possible or not
nope
you should not remvoe any await
there is a reason functions are async
store the promise returned by deferReply, run your logic, then await the stored promise before you editReply or followUp
if they werent meant to be async, you would not have to await them
was thinking of doing this but was hoping for a easier way, but looks like this'll have to be the route, ty
you could do the editReply/followUp in a .then but either way you need to store the original promise
hmm yeah true
was hoping there's a method that replies regardless of if the message is deferred or not, but from the sounds of it seems like discord doesn't work like that
ty
you can't cancel a defer reliably