1
0
Fork 0
mirror of https://github.com/diamondburned/cchat-discord.git synced 2024-11-26 16:12:47 +00:00

Fixed bug where categories or channels don't show up

This commit is contained in:
diamondburned 2020-07-07 00:41:14 -07:00
parent 983e18a9d5
commit bea81ed346
2 changed files with 16 additions and 9 deletions

View file

@ -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)
}
}
}

View file

@ -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",
}
}