Cleanup last PR

pull/479/head
Tyrrrz 4 years ago
parent 07ac805677
commit 39a33538fe

@ -11,14 +11,14 @@ namespace DiscordChatExporter.Domain.Discord.Models
// https://discord.com/developers/docs/resources/channel#message-object-message-types
public enum MessageType
{
Default,
RecipientAdd,
RecipientRemove,
Call,
ChannelNameChange,
ChannelIconChange,
ChannelPinnedMessage,
GuildMemberJoin,
Default = 0,
RecipientAdd = 1,
RecipientRemove = 2,
Call = 3,
ChannelNameChange = 4,
ChannelIconChange = 5,
ChannelPinnedMessage = 6,
GuildMemberJoin = 7,
Reply = 19
}
@ -49,9 +49,9 @@ namespace DiscordChatExporter.Domain.Discord.Models
public IReadOnlyList<User> MentionedUsers { get; }
public MessageReference? Reference {get; }
public MessageReference? Reference { get; }
public Message? ReferencedMessage {get; }
public Message? ReferencedMessage { get; }
public Message(
Snowflake id,
@ -107,7 +107,7 @@ namespace DiscordChatExporter.Domain.Discord.Models
MessageType.RecipientAdd => "Added a recipient.",
MessageType.RecipientRemove => "Removed a recipient.",
MessageType.Call =>
$"Started a call that lasted {callEndedTimestamp?.Pipe(t => t - timestamp).Pipe(t => (int) t.TotalMinutes) ?? 0} minutes.",
$"Started a call that lasted {callEndedTimestamp?.Pipe(t => t - timestamp).Pipe(t => (int) t.TotalMinutes) ?? 0} minutes.",
MessageType.ChannelNameChange => "Changed the channel name.",
MessageType.ChannelIconChange => "Changed the channel icon.",
MessageType.ChannelPinnedMessage => "Pinned a message.",

@ -1,37 +1,37 @@
using System.Text.Json;
using DiscordChatExporter.Domain.Utilities;
using JsonExtensions.Reading;
namespace DiscordChatExporter.Domain.Discord.Models
{
// reference data sent with crossposted messages and replies
// https://discord.com/developers/docs/resources/channel#message-object-message-reference-structure
public partial class MessageReference
{
public string? MessageId { get; }
public Snowflake? MessageId { get; }
public string? ChannelId { get; }
public Snowflake? ChannelId { get; }
public string? GuildId { get; }
public Snowflake? GuildId { get; }
public MessageReference(string? message_id, string? channel_id, string? guild_id)
public MessageReference(Snowflake? messageId, Snowflake? channelId, Snowflake? guildId)
{
MessageId = message_id;
ChannelId = channel_id;
GuildId = guild_id;
MessageId = messageId;
ChannelId = channelId;
GuildId = guildId;
}
public override string ToString() => MessageId ?? "?";
public override string ToString() => MessageId?.ToString() ?? "<unknown reference>";
}
public partial class MessageReference
{
public static MessageReference Parse(JsonElement json)
{
var message_id = json.GetPropertyOrNull("message_id")?.GetString();
var channel_id = json.GetPropertyOrNull("channel_id")?.GetString();
var guild_id = json.GetPropertyOrNull("guild_id")?.GetString();
var messageId = json.GetPropertyOrNull("message_id")?.GetString().Pipe(Snowflake.Parse);
var channelId = json.GetPropertyOrNull("channel_id")?.GetString().Pipe(Snowflake.Parse);
var guildId = json.GetPropertyOrNull("guild_id")?.GetString().Pipe(Snowflake.Parse);
return new MessageReference(message_id, channel_id, guild_id);
return new MessageReference(messageId, channelId, guildId);
}
}
}

@ -22,13 +22,13 @@ namespace DiscordChatExporter.Domain.Exporting.Writers.Html
User author,
DateTimeOffset timestamp,
MessageReference? reference,
Message? referenced_message,
Message? referencedMessage,
IReadOnlyList<Message> messages)
{
Author = author;
Timestamp = timestamp;
Reference = reference;
ReferencedMessage = referenced_message;
ReferencedMessage = referencedMessage;
Messages = messages;
}
}

Loading…
Cancel
Save