client: don't nil out discordgo.Session when disconnecting

I don't have the logs anymore unfortunately, but I witnessed a
(seemingly?) rare nil dereference _within discordgo's event handling
code_ after Disconnect on the client was called (caused by SIGINT). My
thinking is that this caused the Session to get garbage collected, so
the method receiver became nil out from under it.

To let discordgo clean up after itself, keep a reference to it in the
client.
This commit is contained in:
Skip R
2025-12-18 18:28:07 -08:00
parent 776ddd7c96
commit 2075a4b853

View File

@@ -149,7 +149,6 @@ func (cl *DiscordClient) connect(ctx context.Context) error {
func (d *DiscordClient) Disconnect() {
d.UserLogin.Log.Info().Msg("Disconnecting session")
d.Session.Close()
d.Session = nil
}
func (d *DiscordClient) IsLoggedIn() bool {