mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-05-11 14:53:48 +00:00
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:
committed by
GitHub
parent
f6e710909c
commit
ea0b47f26d
@@ -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 | Outputs the list of channels in the given server(s) |
|
||||||
| list channels dm | Outputs the list of direct message channels |
|
| list channels dm | Outputs the list of direct message channels |
|
||||||
| list servers | Outputs the list of accessible servers |
|
| 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 |
|
| 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`.
|
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
|
./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
|
```console
|
||||||
./dce list channels 21814 | ./dce list unwrap | ./dce export
|
./dce list channels 21814 | ./dce list unwrap | ./dce export
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ namespace DiscordChatExporter.Cli.Commands;
|
|||||||
|
|
||||||
[Command(
|
[Command(
|
||||||
"list unwrap",
|
"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
|
public partial class UnwrapChannelsCommand : DiscordCommandBase
|
||||||
{
|
{
|
||||||
@@ -55,6 +55,7 @@ public partial class UnwrapChannelsCommand : DiscordCommandBase
|
|||||||
{
|
{
|
||||||
if (channel.IsCategory)
|
if (channel.IsCategory)
|
||||||
{
|
{
|
||||||
|
// Expand category to its child channels
|
||||||
var guildChannels =
|
var guildChannels =
|
||||||
channelsByGuild.GetValueOrDefault(channel.GuildId)
|
channelsByGuild.GetValueOrDefault(channel.GuildId)
|
||||||
?? await Discord.GetGuildChannelsAsync(channel.GuildId, cancellationToken);
|
?? await Discord.GetGuildChannelsAsync(channel.GuildId, cancellationToken);
|
||||||
@@ -67,6 +68,17 @@ public partial class UnwrapChannelsCommand : DiscordCommandBase
|
|||||||
|
|
||||||
channelsByGuild[channel.GuildId] = guildChannels;
|
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
|
else
|
||||||
{
|
{
|
||||||
result.Add(channel);
|
result.Add(channel);
|
||||||
|
|||||||
Reference in New Issue
Block a user