Add --include-threads and --include-archived-threads to exportguild

Related to #1119
This commit is contained in:
Tyrrrz
2023-08-21 17:33:22 +03:00
parent d1d560fb55
commit eac974cfb1
4 changed files with 50 additions and 6 deletions

View File

@@ -2,6 +2,7 @@
using System.Linq;
using System.Threading.Tasks;
using CliFx.Attributes;
using CliFx.Exceptions;
using CliFx.Infrastructure;
using DiscordChatExporter.Cli.Commands.Base;
using DiscordChatExporter.Core.Discord;
@@ -28,18 +29,28 @@ public class GetChannelsCommand : DiscordCommandBase
[CommandOption(
"include-threads",
Description = "Include threads in the output."
Description = "Include threads."
)]
public bool IncludeThreads { get; init; }
public bool IncludeThreads { get; init; } = false;
[CommandOption(
"include-archived-threads",
Description = "Include archived threads in the output."
Description = "Include archived threads."
)]
public bool IncludeArchivedThreads { get; init; }
public bool IncludeArchivedThreads { get; init; } = false;
public override async ValueTask ExecuteAsync(IConsole console)
{
await base.ExecuteAsync(console);
// Cannot include archived threads without including active threads as well
if (IncludeArchivedThreads && !IncludeThreads)
{
throw new CommandException(
"Option --include-archived-threads can only be used when --include-threads is also specified."
);
}
var cancellationToken = console.RegisterCancellationHandler();
var channels = (await Discord.GetGuildChannelsAsync(GuildId, cancellationToken))