handlediscord: bridge guild delete

This commit is contained in:
Skip R
2026-02-11 17:37:40 -08:00
parent 82aab381ab
commit 07ba87f9d6
2 changed files with 25 additions and 0 deletions

View File

@@ -242,6 +242,7 @@ func (d *DiscordClient) handleDiscordEvent(rawEvt any) {
log := d.UserLogin.Log.With().Str("action", "handle discord event").
Type("event_type", rawEvt).
Logger()
ctx := log.WithContext(d.UserLogin.Bridge.BackgroundCtx)
switch evt := rawEvt.(type) {
case *discordgo.Ready:
@@ -286,6 +287,13 @@ func (d *DiscordClient) handleDiscordEvent(rawEvt any) {
// TODO case *discordgo.MessageReactionRemoveEmoji: (needs impl. in discordgo)
case *discordgo.PresenceUpdate:
return
case *discordgo.GuildDelete:
if evt.Unavailable {
log.Warn().Str("guild_id", evt.ID).Msg("Guild became unavailable")
// For now, leave the portals alone if the guild only went away due to an outage.
return
}
d.deleteGuildPortalSpace(ctx, evt.ID)
case *discordgo.Event:
// For presently unknown reasons sometimes discordgo won't unmarshal
// events into their proper corresponding structs.