You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1.4 KiB
36 lines
1.4 KiB
using System.Linq;
|
|
using DiscordChatExporter.Core.Discord.Data;
|
|
using DiscordChatExporter.Core.Utils.Extensions;
|
|
|
|
namespace DiscordChatExporter.Core.Exporting;
|
|
|
|
internal static class PlainTextMessageExtensions
|
|
{
|
|
public static string GetFallbackContent(this Message message) => message.Kind switch
|
|
{
|
|
MessageKind.RecipientAdd => message.MentionedUsers.Any()
|
|
? $"Added {message.MentionedUsers.First().Name} to the group."
|
|
: "Added a recipient.",
|
|
|
|
MessageKind.RecipientRemove => message.MentionedUsers.Any()
|
|
? message.Author.Id == message.MentionedUsers.First().Id
|
|
? "Left the group."
|
|
: $"Removed {message.MentionedUsers.First().Name} from the group."
|
|
: "Removed a recipient.",
|
|
|
|
MessageKind.Call =>
|
|
$"Started a call that lasted {message.CallEndedTimestamp?.Pipe(t => t - message.Timestamp).Pipe(t => (int)t.TotalMinutes) ?? 0} minutes.",
|
|
|
|
MessageKind.ChannelNameChange =>
|
|
!string.IsNullOrWhiteSpace(message.Content)
|
|
? $"Changed the channel name: {message.Content}"
|
|
: "Changed the channel name.",
|
|
|
|
MessageKind.ChannelIconChange => "Changed the channel icon.",
|
|
MessageKind.ChannelPinnedMessage => "Pinned a message.",
|
|
MessageKind.ThreadCreated => "Started a thread.",
|
|
MessageKind.GuildMemberJoin => "Joined the server.",
|
|
|
|
_ => message.Content
|
|
};
|
|
} |