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:
@@ -149,7 +149,6 @@ func (cl *DiscordClient) connect(ctx context.Context) error {
|
|||||||
func (d *DiscordClient) Disconnect() {
|
func (d *DiscordClient) Disconnect() {
|
||||||
d.UserLogin.Log.Info().Msg("Disconnecting session")
|
d.UserLogin.Log.Info().Msg("Disconnecting session")
|
||||||
d.Session.Close()
|
d.Session.Close()
|
||||||
d.Session = nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DiscordClient) IsLoggedIn() bool {
|
func (d *DiscordClient) IsLoggedIn() bool {
|
||||||
|
|||||||
Reference in New Issue
Block a user