Skip to content

Commit

Permalink
fix nil panic in message reaction add handler (#347)
Browse files Browse the repository at this point in the history
  • Loading branch information
topi314 authored Mar 26, 2024
1 parent 0f6192b commit 3b0882e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion handlers/message_reaction_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package handlers

import (
"github.com/disgoorg/disgo/bot"
"github.com/disgoorg/disgo/discord"
"github.com/disgoorg/disgo/events"
"github.com/disgoorg/disgo/gateway"
)
Expand Down Expand Up @@ -37,6 +38,11 @@ func gatewayHandlerMessageReactionAdd(client bot.Client, sequenceNumber int, sha
MessageAuthorID: event.MessageAuthorID,
})
} else {
var member discord.Member
// sometimes the member is nil for some reason
if event.Member != nil {
member = *event.Member
}
client.EventManager().DispatchEvent(&events.GuildMessageReactionAdd{
GenericGuildMessageReaction: &events.GenericGuildMessageReaction{
GenericEvent: genericEvent,
Expand All @@ -48,7 +54,7 @@ func gatewayHandlerMessageReactionAdd(client bot.Client, sequenceNumber int, sha
BurstColors: event.BurstColors,
Burst: event.Burst,
},
Member: *event.Member,
Member: member,
MessageAuthorID: event.MessageAuthorID,
})
}
Expand Down

0 comments on commit 3b0882e

Please sign in to comment.