Skip to content

Commit

Permalink
fix for panic on nil guildMessages list
Browse files Browse the repository at this point in the history
  • Loading branch information
ashishjh-bst committed Jun 16, 2024
1 parent d0bb874 commit 4cbb5f4
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/dstate/inmemorytracker/tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,14 @@ func (shard *ShardTracker) handleMessageCreate(m *discordgo.MessageCreate) {

// Insert *list.Element.Value into guildMessages so that we only need to perform
// state changes for the channel lists
shard.guildMessages[m.GuildID].PushBack(&elem.Value)
// Ensure that the guildMessages list is created as guildCreate events could be missed
if gc, ok := shard.guildMessages[m.GuildID]; ok {
gc.PushBack(&elem.Value)
} else {
gc := list.New()
gc.PushBack(&elem.Value)
shard.guildMessages[m.GuildID] = gc
}
}

func (shard *ShardTracker) handleMessageUpdate(m *discordgo.MessageUpdate) {
Expand Down

0 comments on commit 4cbb5f4

Please sign in to comment.