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

@@ -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

View File

@@ -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;
}

View File

@@ -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(

View File

@@ -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)