mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2025-05-27 21:24:12 -04:00
Add CLI option to include or exclude voice channels in exportall
and exportguild
This commit is contained in:
parent
bd4cfcdaf6
commit
d4f62387a5
6 changed files with 23 additions and 3 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -18,7 +18,8 @@ public partial record Channel(
|
|||
string? Topic,
|
||||
Snowflake? LastMessageId) : IHasId
|
||||
{
|
||||
public bool IsVoice => Kind is ChannelKind.GuildVoiceChat or ChannelKind.GuildStageVoice;
|
||||
// Only needed for WPF data binding. Don't use anywhere else.
|
||||
public bool IsVoice => Kind.IsVoice();
|
||||
}
|
||||
|
||||
public partial record Channel
|
||||
|
|
|
@ -24,4 +24,7 @@ public static class ChannelKindExtensions
|
|||
|
||||
public static bool IsGuild(this ChannelKind kind) =>
|
||||
!kind.IsDirect();
|
||||
|
||||
public static bool IsVoice(this ChannelKind kind) =>
|
||||
kind is ChannelKind.GuildVoiceChat or ChannelKind.GuildStageVoice;
|
||||
}
|
|
@ -261,7 +261,7 @@ internal partial class HtmlMarkdownVisitor : MarkdownVisitor
|
|||
else if (mention.Kind == MentionKind.Channel)
|
||||
{
|
||||
var channel = mention.TargetId?.Pipe(_context.TryGetChannel);
|
||||
var symbol = channel?.IsVoice == true ? "🔊" : "#";
|
||||
var symbol = channel?.Kind.IsVoice() == true ? "🔊" : "#";
|
||||
var name = channel?.Name ?? "deleted-channel";
|
||||
|
||||
_buffer.Append(
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using DiscordChatExporter.Core.Discord.Data;
|
||||
using DiscordChatExporter.Core.Markdown;
|
||||
using DiscordChatExporter.Core.Markdown.Parsing;
|
||||
using DiscordChatExporter.Core.Utils.Extensions;
|
||||
|
@ -71,7 +72,7 @@ internal partial class PlainTextMarkdownVisitor : MarkdownVisitor
|
|||
_buffer.Append($"#{name}");
|
||||
|
||||
// Voice channel marker
|
||||
if (channel?.IsVoice == true)
|
||||
if (channel?.Kind.IsVoice() == true)
|
||||
_buffer.Append(" [voice]");
|
||||
}
|
||||
else if (mention.Kind == MentionKind.Role)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue