mirror of
https://github.com/hrfee/jfa-go.git
synced 2024-12-22 17:10:10 +00:00
Discord: Wait for non-nil pointer to bot data
While testing others things, I had quite a few nil pointer dereference errors from accessing bot data right after initializing. A for loop now waits until the first of the pointers is non-nil, which should hopefully avoid crashes.
This commit is contained in:
parent
44558b8109
commit
24fa841c0d
@ -76,6 +76,10 @@ func (d *DiscordDaemon) run() {
|
||||
d.app.err.Printf("Discord: Failed to start daemon: %v", err)
|
||||
return
|
||||
}
|
||||
// Sometimes bot.State isn't populated quick enough
|
||||
for d.bot.State == nil {
|
||||
continue
|
||||
}
|
||||
d.username = d.bot.State.User.Username
|
||||
// Choose the last guild (server), for now we don't really support multiple anyway
|
||||
guild, err := d.bot.Guild(d.bot.State.Guilds[len(d.bot.State.Guilds)-1].ID)
|
||||
|
Loading…
Reference in New Issue
Block a user