|
|
|
@ -1,6 +1,8 @@
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System;
|
|
|
|
|
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;
|
|
|
|
@ -25,10 +27,30 @@ public class ExportGuildCommand : ExportCommandBase
|
|
|
|
|
)]
|
|
|
|
|
public bool IncludeVoiceChannels { get; init; } = true;
|
|
|
|
|
|
|
|
|
|
[CommandOption(
|
|
|
|
|
"include-threads",
|
|
|
|
|
Description = "Include threads."
|
|
|
|
|
)]
|
|
|
|
|
public bool IncludeThreads { get; init; } = false;
|
|
|
|
|
|
|
|
|
|
[CommandOption(
|
|
|
|
|
"include-archived-threads",
|
|
|
|
|
Description = "Include archived threads."
|
|
|
|
|
)]
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
|
|
await console.Output.WriteLineAsync("Fetching channels...");
|
|
|
|
@ -38,6 +60,13 @@ public class ExportGuildCommand : ExportCommandBase
|
|
|
|
|
.Where(c => IncludeVoiceChannels || !c.Kind.IsVoice())
|
|
|
|
|
.ToArray();
|
|
|
|
|
|
|
|
|
|
await ExportAsync(console, channels);
|
|
|
|
|
var threads = IncludeThreads
|
|
|
|
|
? await Discord.GetGuildThreadsAsync(GuildId, IncludeArchivedThreads, cancellationToken)
|
|
|
|
|
: Array.Empty<Channel>();
|
|
|
|
|
|
|
|
|
|
await ExportAsync(
|
|
|
|
|
console,
|
|
|
|
|
channels.Concat(threads).ToArray()
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|