connector: break out guild bridging logic into method

This commit is contained in:
Skip R
2026-01-21 06:54:58 -08:00
parent b4fdd8b9ed
commit 5e0f9b909a

View File

@@ -360,16 +360,26 @@ func (d *DiscordClient) syncGuilds(ctx context.Context) {
Str("action", "sync guild").
Logger()
err := d.bridgeGuild(log.WithContext(ctx), guildID)
if err != nil {
log.Err(err).Msg("Couldn't bridge guild during sync")
}
}
}
func (d *DiscordClient) bridgeGuild(ctx context.Context, guildID string) error {
log := zerolog.Ctx(ctx)
guild, err := d.Session.State.Guild(guildID)
if errors.Is(err, discordgo.ErrStateNotFound) || guild == nil {
log.Err(err).Msg("Couldn't find guild, user isn't a member?")
continue
return errors.New("couldn't find guild in state")
}
err = d.syncGuildSpace(ctx, guild)
if err != nil {
log.Err(err).Msg("Couldn't sync guild space portal")
continue
return fmt.Errorf("couldn't sync guild space portal: %w", err)
}
for _, guildCh := range guild.Channels {
@@ -402,10 +412,10 @@ func (d *DiscordClient) syncGuilds(ctx context.Context) {
Threads: true,
})
if err != nil {
log.Warn().Err(err).Msg("Failed to subscribe to guild")
}
log.Warn().Err(err).Msg("Failed to subscribe to guild; proceeding")
}
return nil
}
func simpleDownload(ctx context.Context, url, thing string) ([]byte, error) {