|
|
|
@ -34,6 +34,18 @@ public class ExportAllCommand : 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;
|
|
|
|
|
|
|
|
|
|
[CommandOption(
|
|
|
|
|
"data-package",
|
|
|
|
|
Description =
|
|
|
|
@ -46,6 +58,14 @@ public class ExportAllCommand : ExportCommandBase
|
|
|
|
|
{
|
|
|
|
|
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 = new List<Channel>();
|
|
|
|
|
|
|
|
|
@ -56,10 +76,26 @@ public class ExportAllCommand : ExportCommandBase
|
|
|
|
|
|
|
|
|
|
await foreach (var guild in Discord.GetUserGuildsAsync(cancellationToken))
|
|
|
|
|
{
|
|
|
|
|
// Regular channels
|
|
|
|
|
await foreach (var channel in Discord.GetGuildChannelsAsync(guild.Id, cancellationToken))
|
|
|
|
|
{
|
|
|
|
|
if (channel.Kind == ChannelKind.GuildCategory)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (!IncludeVoiceChannels && channel.Kind.IsVoice())
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
channels.Add(channel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Threads
|
|
|
|
|
if (IncludeThreads)
|
|
|
|
|
{
|
|
|
|
|
await foreach (var thread in Discord.GetGuildThreadsAsync(guild.Id, IncludeArchivedThreads, cancellationToken))
|
|
|
|
|
{
|
|
|
|
|
channels.Add(thread);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Pull from the data package
|
|
|
|
@ -105,6 +141,10 @@ public class ExportAllCommand : ExportCommandBase
|
|
|
|
|
channels.RemoveAll(c => c.Kind.IsGuild());
|
|
|
|
|
if (!IncludeVoiceChannels)
|
|
|
|
|
channels.RemoveAll(c => c.Kind.IsVoice());
|
|
|
|
|
if (!IncludeThreads)
|
|
|
|
|
channels.RemoveAll(c => c.Kind.IsThread());
|
|
|
|
|
if (!IncludeArchivedThreads)
|
|
|
|
|
channels.RemoveAll(c => c.Kind.IsThread() && c.IsArchived);
|
|
|
|
|
|
|
|
|
|
await ExportAsync(console, channels);
|
|
|
|
|
}
|
|
|
|
|