diff --git a/DiscordChatExporter.Core/Discord/Data/Message.cs b/DiscordChatExporter.Core/Discord/Data/Message.cs index e0fee0a..330c568 100644 --- a/DiscordChatExporter.Core/Discord/Data/Message.cs +++ b/DiscordChatExporter.Core/Discord/Data/Message.cs @@ -13,6 +13,7 @@ namespace DiscordChatExporter.Core.Discord.Data; public record Message( Snowflake Id, MessageKind Kind, + MessageFlags Flags, User Author, DateTimeOffset Timestamp, DateTimeOffset? EditedTimestamp, @@ -87,6 +88,7 @@ public record Message( { var id = json.GetProperty("id").GetNonWhiteSpaceString().Pipe(Snowflake.Parse); var kind = (MessageKind)json.GetProperty("type").GetInt32(); + var flags = (MessageFlags?)json.GetPropertyOrNull("flags")?.GetInt32() ?? MessageFlags.None; var author = json.GetProperty("author").Pipe(User.Parse); var timestamp = json.GetProperty("timestamp").GetDateTimeOffset(); @@ -139,6 +141,7 @@ public record Message( return new Message( id, kind, + flags, author, timestamp, editedTimestamp, diff --git a/DiscordChatExporter.Core/Discord/Data/MessageFlags.cs b/DiscordChatExporter.Core/Discord/Data/MessageFlags.cs new file mode 100644 index 0000000..69461f6 --- /dev/null +++ b/DiscordChatExporter.Core/Discord/Data/MessageFlags.cs @@ -0,0 +1,18 @@ +using System; + +namespace DiscordChatExporter.Core.Discord.Data; + +// https://discord.com/developers/docs/resources/channel#message-object-message-flags +[Flags] +public enum MessageFlags +{ + None = 0, + CrossPosted = 1, + CrossPost = 2, + SuppressEmbeds = 4, + SourceMessageDeleted = 8, + Urgent = 16, + HasThread = 32, + Ephemeral = 64, + Loading = 128 +} \ No newline at end of file diff --git a/DiscordChatExporter.Core/Exporting/MessageGroupTemplate.cshtml b/DiscordChatExporter.Core/Exporting/MessageGroupTemplate.cshtml index 47b4402..5bd3f68 100644 --- a/DiscordChatExporter.Core/Exporting/MessageGroupTemplate.cshtml +++ b/DiscordChatExporter.Core/Exporting/MessageGroupTemplate.cshtml @@ -167,11 +167,11 @@ @{/* Author name */} @userNick - @{/* Bot label */} + @{/* Bot tag */} @if (message.Author.IsBot) { // For cross-posts, the BOT tag is replaced with the SERVER tag - if (message.Kind != MessageKind.Reply && message.Reference is not null && message.Reference.GuildId != ExportContext.Request.Guild.Id) + if (message.Flags.HasFlag(MessageFlags.CrossPost)) { SERVER }