mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2025-05-25 04:04:22 -04:00
Reimplement previous changes using message flags
This commit is contained in:
parent
049338009e
commit
a95d2ef298
3 changed files with 23 additions and 2 deletions
|
@ -13,6 +13,7 @@ namespace DiscordChatExporter.Core.Discord.Data;
|
||||||
public record Message(
|
public record Message(
|
||||||
Snowflake Id,
|
Snowflake Id,
|
||||||
MessageKind Kind,
|
MessageKind Kind,
|
||||||
|
MessageFlags Flags,
|
||||||
User Author,
|
User Author,
|
||||||
DateTimeOffset Timestamp,
|
DateTimeOffset Timestamp,
|
||||||
DateTimeOffset? EditedTimestamp,
|
DateTimeOffset? EditedTimestamp,
|
||||||
|
@ -87,6 +88,7 @@ public record Message(
|
||||||
{
|
{
|
||||||
var id = json.GetProperty("id").GetNonWhiteSpaceString().Pipe(Snowflake.Parse);
|
var id = json.GetProperty("id").GetNonWhiteSpaceString().Pipe(Snowflake.Parse);
|
||||||
var kind = (MessageKind)json.GetProperty("type").GetInt32();
|
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 author = json.GetProperty("author").Pipe(User.Parse);
|
||||||
|
|
||||||
var timestamp = json.GetProperty("timestamp").GetDateTimeOffset();
|
var timestamp = json.GetProperty("timestamp").GetDateTimeOffset();
|
||||||
|
@ -139,6 +141,7 @@ public record Message(
|
||||||
return new Message(
|
return new Message(
|
||||||
id,
|
id,
|
||||||
kind,
|
kind,
|
||||||
|
flags,
|
||||||
author,
|
author,
|
||||||
timestamp,
|
timestamp,
|
||||||
editedTimestamp,
|
editedTimestamp,
|
||||||
|
|
18
DiscordChatExporter.Core/Discord/Data/MessageFlags.cs
Normal file
18
DiscordChatExporter.Core/Discord/Data/MessageFlags.cs
Normal file
|
@ -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
|
||||||
|
}
|
|
@ -167,11 +167,11 @@
|
||||||
@{/* Author name */}
|
@{/* Author name */}
|
||||||
<span class="chatlog__author" style="@(userColor is not null ? $"color: rgb({userColor.Value.R}, {userColor.Value.G}, {userColor.Value.B})" : null)" title="@message.Author.FullName" data-user-id="@message.Author.Id">@userNick</span>
|
<span class="chatlog__author" style="@(userColor is not null ? $"color: rgb({userColor.Value.R}, {userColor.Value.G}, {userColor.Value.B})" : null)" title="@message.Author.FullName" data-user-id="@message.Author.Id">@userNick</span>
|
||||||
|
|
||||||
@{/* Bot label */}
|
@{/* Bot tag */}
|
||||||
@if (message.Author.IsBot)
|
@if (message.Author.IsBot)
|
||||||
{
|
{
|
||||||
// For cross-posts, the BOT tag is replaced with the SERVER tag
|
// 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))
|
||||||
{
|
{
|
||||||
<span class="chatlog__author-tag">SERVER</span>
|
<span class="chatlog__author-tag">SERVER</span>
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue