From 2075a4b853eec8aeffdd9f3928250898b1ebdc5a Mon Sep 17 00:00:00 2001 From: Skip R Date: Thu, 18 Dec 2025 18:28:07 -0800 Subject: [PATCH] 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. --- pkg/connector/client.go | 1 - 1 file changed, 1 deletion(-) diff --git a/pkg/connector/client.go b/pkg/connector/client.go index 42fed05..cb92dd5 100644 --- a/pkg/connector/client.go +++ b/pkg/connector/client.go @@ -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 {