Preliminary support for threads (#1032)

This commit is contained in:
William Unsworth
2023-05-18 16:46:37 -06:00
committed by GitHub
parent 9048557b17
commit 25caf04445
3 changed files with 111 additions and 0 deletions

View File

@@ -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}");
}
}
}
}
}