Expand list unwrap to also resolve forum channels to thread posts

Agent-Logs-Url: https://github.com/Tyrrrz/DiscordChatExporter/sessions/674ba90d-1778-4427-b50a-30bc50195319

Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-04-04 20:49:33 +00:00 committed by GitHub
parent f6e710909c
commit ea0b47f26d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 4 deletions

View File

@ -39,7 +39,7 @@ Type the following command in your terminal of choice, then press ENTER to run i
| list channels | Outputs the list of channels in the given server(s) |
| list channels dm | Outputs the list of direct message channels |
| list servers | Outputs the list of accessible servers |
| list unwrap | Resolves categories in a channel list to their child channels |
| list unwrap | Resolves categories and forums in a channel list to their child channels and threads |
| guide | Explains how to obtain token, server, and channel ID |
To use the commands, you'll need a token. For the instructions on how to get a token, please refer to [this page](Token-and-IDs.md), or run `./dce guide`.
@ -331,9 +331,9 @@ The `list channels dm` command outputs a JSON array of channel objects. You can
./dce list channels dm | ./dce export
```
### Unwrap categories
### Unwrap categories and forums
To resolve category channels in a list to their child channels, use the `list unwrap` command:
To resolve category and forum channels in a list to their child channels and thread posts, use the `list unwrap` command:
```console
./dce list channels 21814 | ./dce list unwrap | ./dce export

View File

@ -16,7 +16,7 @@ namespace DiscordChatExporter.Cli.Commands;
[Command(
"list unwrap",
Description = "Resolves categories in a channel list to their child channels."
Description = "Resolves categories and forums in a channel list to their child channels and threads."
)]
public partial class UnwrapChannelsCommand : DiscordCommandBase
{
@ -55,6 +55,7 @@ public partial class UnwrapChannelsCommand : DiscordCommandBase
{
if (channel.IsCategory)
{
// Expand category to its child channels
var guildChannels =
channelsByGuild.GetValueOrDefault(channel.GuildId)
?? await Discord.GetGuildChannelsAsync(channel.GuildId, cancellationToken);
@ -67,6 +68,17 @@ public partial class UnwrapChannelsCommand : DiscordCommandBase
channelsByGuild[channel.GuildId] = guildChannels;
}
else if (channel.Kind == ChannelKind.GuildForum)
{
// Expand forum to its thread posts
await foreach (
var thread in Discord.GetChannelThreadsAsync(
[channel],
cancellationToken: cancellationToken
)
)
result.Add(thread);
}
else
{
result.Add(channel);