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:
parent
983e18a9d5
commit
bea81ed346
21
channel.go
21
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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",
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue