mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-04-22 22:18:24 +00:00
Preliminary support for threads (#1032)
This commit is contained in:
@@ -20,6 +20,12 @@ public class GetChannelsCommand : DiscordCommandBase
|
||||
)]
|
||||
public required Snowflake GuildId { get; init; }
|
||||
|
||||
[CommandOption(
|
||||
"include-threads",
|
||||
Description = "Display threads alongside channels."
|
||||
)]
|
||||
public bool IncludeTHreads { get; init; }
|
||||
|
||||
public override async ValueTask ExecuteAsync(IConsole console)
|
||||
{
|
||||
var cancellationToken = console.RegisterCancellationHandler();
|
||||
@@ -44,6 +50,32 @@ public class GetChannelsCommand : DiscordCommandBase
|
||||
// Channel category / name
|
||||
using (console.WithForegroundColor(ConsoleColor.White))
|
||||
await console.Output.WriteLineAsync($"{channel.Category.Name} / {channel.Name}");
|
||||
|
||||
if (IncludeThreads)
|
||||
{
|
||||
var threads = (await Discord.GetGuildChannelThreadsAsync(channel.Id.ToString(), cancellationToken))
|
||||
.OrderBy(c => c.Name)
|
||||
.ToArray();
|
||||
|
||||
foreach (var thread in threads)
|
||||
{
|
||||
// Indent
|
||||
await console.Output.WriteAsync('\t');
|
||||
|
||||
// Thread ID
|
||||
await console.Output.WriteAsync(
|
||||
thread.Id.ToString().PadRight(18, ' ')
|
||||
);
|
||||
|
||||
// Separator
|
||||
using (console.WithForegroundColor(ConsoleColor.DarkGray))
|
||||
await console.Output.WriteAsync(" | ");
|
||||
|
||||
// Thread / thread name
|
||||
using (console.WithForegroundColor(ConsoleColor.White))
|
||||
await console.Output.WriteLineAsync($"Thread / {thread.Name}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user