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 // https://discord.com/developers/docs/resources/channel#message-object-message-types
public enum MessageType public enum MessageType
{ {
Default, Default = 0,
RecipientAdd, RecipientAdd = 1,
RecipientRemove, RecipientRemove = 2,
Call, Call = 3,
ChannelNameChange, ChannelNameChange = 4,
ChannelIconChange, ChannelIconChange = 5,
ChannelPinnedMessage, ChannelPinnedMessage = 6,
GuildMemberJoin, GuildMemberJoin = 7,
Reply = 19 Reply = 19
} }
@ -49,9 +49,9 @@ namespace DiscordChatExporter.Domain.Discord.Models
public IReadOnlyList<User> MentionedUsers { get; } public IReadOnlyList<User> MentionedUsers { get; }
public MessageReference? Reference {get; } public MessageReference? Reference { get; }
public Message? ReferencedMessage {get; } public Message? ReferencedMessage { get; }
public Message( public Message(
Snowflake id, Snowflake id,
@ -107,7 +107,7 @@ namespace DiscordChatExporter.Domain.Discord.Models
MessageType.RecipientAdd => "Added a recipient.", MessageType.RecipientAdd => "Added a recipient.",
MessageType.RecipientRemove => "Removed a recipient.", MessageType.RecipientRemove => "Removed a recipient.",
MessageType.Call => 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.ChannelNameChange => "Changed the channel name.",
MessageType.ChannelIconChange => "Changed the channel icon.", MessageType.ChannelIconChange => "Changed the channel icon.",
MessageType.ChannelPinnedMessage => "Pinned a message.", MessageType.ChannelPinnedMessage => "Pinned a message.",

@ -1,37 +1,37 @@
using System.Text.Json; using System.Text.Json;
using DiscordChatExporter.Domain.Utilities;
using JsonExtensions.Reading; using JsonExtensions.Reading;
namespace DiscordChatExporter.Domain.Discord.Models 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 // https://discord.com/developers/docs/resources/channel#message-object-message-reference-structure
public partial class MessageReference 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; MessageId = messageId;
ChannelId = channel_id; ChannelId = channelId;
GuildId = guild_id; GuildId = guildId;
} }
public override string ToString() => MessageId ?? "?"; public override string ToString() => MessageId?.ToString() ?? "<unknown reference>";
} }
public partial class MessageReference public partial class MessageReference
{ {
public static MessageReference Parse(JsonElement json) public static MessageReference Parse(JsonElement json)
{ {
var message_id = json.GetPropertyOrNull("message_id")?.GetString(); var messageId = json.GetPropertyOrNull("message_id")?.GetString().Pipe(Snowflake.Parse);
var channel_id = json.GetPropertyOrNull("channel_id")?.GetString(); var channelId = json.GetPropertyOrNull("channel_id")?.GetString().Pipe(Snowflake.Parse);
var guild_id = json.GetPropertyOrNull("guild_id")?.GetString(); 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, User author,
DateTimeOffset timestamp, DateTimeOffset timestamp,
MessageReference? reference, MessageReference? reference,
Message? referenced_message, Message? referencedMessage,
IReadOnlyList<Message> messages) IReadOnlyList<Message> messages)
{ {
Author = author; Author = author;
Timestamp = timestamp; Timestamp = timestamp;
Reference = reference; Reference = reference;
ReferencedMessage = referenced_message; ReferencedMessage = referencedMessage;
Messages = messages; Messages = messages;
} }
} }

Loading…
Cancel
Save