shuppet / raku-api-discord

Raku module for interacting with the Discord API.
https://shuppet.com
BSD 3-Clause "New" or "Revised" License
30 stars 3 forks source link

Implement $discord.disconnect #56

Closed kawaii closed 2 years ago

kawaii commented 3 years ago

We should add a disconnect method which sends a 1000 close code to the websocket. This will allow for graceful shutdown of applications and prevent zombie connections while the heartbeats time out.

@gfldex asked about this in the Discord, just making a note of it here for later.

kawaii commented 3 years ago

From Sinister Rectus in the Discord API developers server;

if you don't disconnect gracefully, then you'll just have a zombied connection that discord will eventually terminate after it doesn't detect a heartbeat. it takes up to about a minute and during that time your bot will appear online (or with its last status and activity) despite not having a real client behind it, so that can be misleading to your users. i believe code 1000 is the appropriate code for a clean disconnect. i think the library should send and you should not rely on users to send i
Altreus commented 2 years ago

Probably this https://github.com/shuppet/raku-api-discord/pull/58

Note optional :script-mode that handles SIGINT for you