Add CLI option to include or exclude voice channels in exportall and exportguild

This commit is contained in:
Tyrrrz
2023-06-23 21:23:55 +03:00
parent bd4cfcdaf6
commit d4f62387a5
6 changed files with 23 additions and 3 deletions

View File

@@ -28,6 +28,12 @@ public class ExportAllCommand : ExportCommandBase
)]
public bool IncludeGuildChannels { get; init; } = true;
[CommandOption(
"include-vc",
Description = "Include voice channels."
)]
public bool IncludeVoiceChannels { get; init; } = true;
[CommandOption(
"data-package",
Description =
@@ -97,6 +103,8 @@ public class ExportAllCommand : ExportCommandBase
channels.RemoveAll(c => c.Kind.IsDirect());
if (!IncludeGuildChannels)
channels.RemoveAll(c => c.Kind.IsGuild());
if (!IncludeVoiceChannels)
channels.RemoveAll(c => c.Kind.IsVoice());
await base.ExecuteAsync(console, channels);
}

View File

@@ -19,6 +19,12 @@ public class ExportGuildCommand : ExportCommandBase
)]
public required Snowflake GuildId { get; init; }
[CommandOption(
"include-vc",
Description = "Include voice channels."
)]
public bool IncludeVoiceChannels { get; init; } = true;
public override async ValueTask ExecuteAsync(IConsole console)
{
await base.ExecuteAsync(console);
@@ -29,6 +35,7 @@ public class ExportGuildCommand : ExportCommandBase
var channels = (await Discord.GetGuildChannelsAsync(GuildId, cancellationToken))
.Where(c => c.Kind != ChannelKind.GuildCategory)
.Where(c => IncludeVoiceChannels || !c.Kind.IsVoice())
.ToArray();
await base.ExecuteAsync(console, channels);