feat(guilds_tree): support for forum channels (#612)

Co-authored-by: Ayyan <ayn2op@gmail.com>
This commit is contained in:
Andrej Novikov 2025-12-25 04:16:44 +02:00 • committed by GitHub
parent 99be800e98
commit ed0dc8e553
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 31 additions and 0 deletions

View file

@ -169,6 +169,35 @@ func (gt *guildsTree) onSelected(node *tview.TreeNode) {
return
}
// Handle forum channels differently - they contain threads, not direct messages
if channel.Type == discord.GuildForum {
// Get all channels from the guild - this includes active threads from GuildCreateEvent
allChannels, err := discordState.Cabinet.Channels(channel.GuildID)
if err != nil {
slog.Error("failed to get channels for forum threads", "err", err, "guild_id", channel.GuildID)
return
}
// Filter for threads that belong to this forum channel
var forumThreads []discord.Channel
for _, ch := range allChannels {
if ch.ParentID == channel.ID && (ch.Type == discord.GuildPublicThread ||
ch.Type == discord.GuildPrivateThread ||
ch.Type == discord.GuildAnnouncementThread) {
forumThreads = append(forumThreads, ch)
}
}
// Add threads as child nodes
for _, thread := range forumThreads {
gt.createChannelNode(node, thread)
}
// Expand the node to show threads
node.SetExpanded(true)
return
}
go discordState.ReadState.MarkRead(channel.ID, channel.LastMessageID)
messages, err := discordState.Messages(channel.ID, uint(gt.cfg.MessagesLimit))

View file

@ -73,6 +73,8 @@ func ChannelToString(channel discord.Channel) string {
return "s-" + channel.Name
case discord.GuildForum:
return "f-" + channel.Name
case discord.GuildPublicThread, discord.GuildPrivateThread, discord.GuildAnnouncementThread:
return "t-" + channel.Name
default:
return channel.Name
}