Print archived threads only if explicitly requested in the channels command

This commit is contained in:
Tyrrrz
2023-08-21 17:22:44 +03:00
parent ac1bd16439
commit 6fba60e570
3 changed files with 41 additions and 24 deletions

View File

@@ -26,6 +26,12 @@ public class GetChannelsCommand : DiscordCommandBase
)]
public bool IncludeThreads { get; init; }
[CommandOption(
"include-archived-threads",
Description = "Include archived threads in the output."
)]
public bool IncludeArchivedThreads { get; init; }
public override async ValueTask ExecuteAsync(IConsole console)
{
var cancellationToken = console.RegisterCancellationHandler();
@@ -42,7 +48,9 @@ public class GetChannelsCommand : DiscordCommandBase
.FirstOrDefault();
var threads = IncludeThreads
? (await Discord.GetGuildThreadsAsync(GuildId, cancellationToken)).OrderBy(c => c.Name).ToArray()
? (await Discord.GetGuildThreadsAsync(GuildId, IncludeArchivedThreads, cancellationToken))
.OrderBy(c => c.Name)
.ToArray()
: Array.Empty<Channel>();
foreach (var channel in channels)
@@ -90,7 +98,7 @@ public class GetChannelsCommand : DiscordCommandBase
// Thread status
using (console.WithForegroundColor(ConsoleColor.White))
await console.Output.WriteLineAsync(channelThread.IsActive ? "Active" : "Archived");
await console.Output.WriteLineAsync(channelThread.IsArchived ? "Archived" : "Active");
}
}
}