diff --git a/channel.go b/channel.go index 7dace03..a69c9fb 100644 --- a/channel.go +++ b/channel.go @@ -33,11 +33,8 @@ func filterAccessible(s *Session, chs []discord.Channel) []discord.Channel { for _, ch := range chs { p, err := s.Permissions(ch.ID, u.ID) - if err != nil { - continue - } - - if p.Has(discord.PermissionViewChannel) { + // Treat error as non-fatal and add the channel anyway. + if err != nil || p.Has(discord.PermissionViewChannel) { filtered = append(filtered, ch) } } @@ -47,10 +44,20 @@ func filterAccessible(s *Session, chs []discord.Channel) []discord.Channel { func filterCategory(chs []discord.Channel, catID discord.Snowflake) []discord.Channel { var filtered = chs[:0] + var catvalid = catID.Valid() for _, ch := range chs { - if ch.CategoryID == catID && chGuildCheck(ch.Type) { - filtered = append(filtered, ch) + switch { + // If the given ID is not valid, then we look for channels with + // similarly invalid category IDs, because yes, Discord really sends + // inconsistent responses. + case !catvalid && !ch.CategoryID.Valid(): + fallthrough + // Basic comparison. + case ch.CategoryID == catID: + if chGuildCheck(ch.Type) { + filtered = append(filtered, ch) + } } } diff --git a/segments/embed.go b/segments/embed.go index 479befe..463a320 100644 --- a/segments/embed.go +++ b/segments/embed.go @@ -154,10 +154,10 @@ func EmbedAuthor(start int, a discord.EmbedAuthor) AvatarSegment { } // EmbedFooter uses an avatar segment to comply with Discord. -func EmbedFooter(start int, a discord.EmbedFooter) AvatarSegment { +func EmbedFooter(start int, f discord.EmbedFooter) AvatarSegment { return AvatarSegment{ start: start, - url: a.ProxyIcon, + url: f.ProxyIcon, text: "Icon", } }