Gracefully stop the bot
Is there any way to gracefully stop the bot? I want it to appear as offline as soon as it stops.
doesn't seem to work…
Also, what's the reason that
setPresence
unlike basically any other similar method isn't async?10 Replies
• What's your exact discord.js
npm list discord.js
and node node -v
version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.I think you need to await the
setPresence
since destroying the client might stop your request from actually firingsetPresence does not return a Promise, it returns the presence synchronically, looking at the type definitions…
(
discord.js/typings/index.d.ts
)
I tried to await another API thing before destroying the client (force fetching the client user, to be exact), but the bot still didn't immediately switch to offline after stopping itI uses the Ws, thats why it's sync
Maybe add an 1-2s cooldown before destroying? idk
Ws? As in websockets?
It calls the websocket to the change, not a rest request and when you destroy the client you also destroy the Ws
That might be the race condition
There's another weird thing: editing a message in the exit handler takes around 15 seconds…
this is the handler
Approximately 15 seconds between
Refreshing volume message…
and Setting offline presence…
, and the only await inside refresh()
is editing a message saved in a variable