connector: fetch @me to create login before creating client

Creating the client before the actual UserLogin is bad form.
This commit is contained in:
Skip R
2026-02-02 22:23:43 -08:00
parent 8c02a80f85
commit 2682175508
3 changed files with 40 additions and 90 deletions

View File

@@ -164,23 +164,6 @@ func (d *DiscordClient) wrapDiscordReaction(reaction *discordgo.MessageReaction,
}
func (d *DiscordClient) handleDiscordEvent(rawEvt any) {
if d.UserLogin == nil {
// Our event handlers are able to assume that a UserLogin is available.
// We respond to special events like READY outside of this function,
// by virtue of methods like Session.Open only returning control flow
// after RESUME or READY.
log := zerolog.Ctx(context.TODO())
log.Trace().Msg("Dropping Discord event received before UserLogin creation")
return
}
if d.Session == nil || d.Session.State == nil || d.Session.State.User == nil {
// Our event handlers are able to assume that we've fully connected to the
// gateway.
d.UserLogin.Log.Debug().Msg("Dropping Discord event received before READY or RESUMED")
return
}
defer func() {
err := recover()
if err != nil {