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
d.js toolkit
d.js toolkit17mo ago
- 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!
treble/luna
treble/luna17mo ago
get a better host / network usually deferreply should not lag a ton
leonissenbaum
leonissenbaumOP17mo ago
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?
treble/luna
treble/luna17mo ago
you should not remove awaits they will break stuff
leonissenbaum
leonissenbaumOP17mo ago
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
treble/luna
treble/luna17mo ago
nope you should not remvoe any await there is a reason functions are async
urretf
urretf17mo ago
store the promise returned by deferReply, run your logic, then await the stored promise before you editReply or followUp
treble/luna
treble/luna17mo ago
if they werent meant to be async, you would not have to await them
leonissenbaum
leonissenbaumOP17mo ago
was thinking of doing this but was hoping for a easier way, but looks like this'll have to be the route, ty
urretf
urretf17mo ago
you could do the editReply/followUp in a .then but either way you need to store the original promise
leonissenbaum
leonissenbaumOP17mo ago
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
urretf
urretf17mo ago
you can't cancel a defer reliably
Want results from more Discord servers?
Add your server