46 lines
1.7 KiB
C#
46 lines
1.7 KiB
C#
using Maki.Structures.Messages;
|
|
using System;
|
|
using System.Linq;
|
|
|
|
namespace Maki
|
|
{
|
|
public class DiscordMessage
|
|
{
|
|
public readonly ulong Id;
|
|
public readonly DateTime Sent;
|
|
public readonly DiscordMember Sender;
|
|
public readonly DiscordChannel Channel;
|
|
private readonly Discord client;
|
|
|
|
public string Text { get; internal set; }
|
|
public DateTime Edited { get; internal set; }
|
|
public DiscordMember[] MentionsUsers { get; internal set; }
|
|
public DiscordRole[] MentionsRoles { get; internal set; }
|
|
public bool MentionsEveryone { get; internal set; }
|
|
|
|
public bool MentionsMe(bool everyone = false, bool roles = true) =>
|
|
(everyone && MentionsEveryone)
|
|
|| (roles && client.members.Where(x => x.User == client.Me && x.Server == Channel.Server).First().Roles.Where(x => MentionsRoles.Contains(x)).Count() > 0)
|
|
|| MentionsUsers.Select(x => x.User).Contains(client.Me);
|
|
|
|
public bool IsMe => client.Me == Sender.User;
|
|
|
|
internal DiscordMessage(Discord discord, Message msg, DiscordMember member, DiscordChannel channel)
|
|
{
|
|
client = discord;
|
|
Id = msg.Id;
|
|
Sent = msg.Sent;
|
|
Text = msg.Content;
|
|
Sender = member;
|
|
Channel = channel;
|
|
MentionsUsers = client.members.Where(x => x.Server == channel.Server && msg.Mentions.Select(y => y.Id).Contains(x.User.Id)).ToArray();
|
|
MentionsRoles = client.roles.Where(x => x.Server == channel.Server && msg.MentionsRoles.Contains(x.Id)).ToArray();
|
|
MentionsEveryone = msg.MentioningEveryone;
|
|
}
|
|
|
|
public DiscordMessage Edit(string text)
|
|
{
|
|
return this;
|
|
}
|
|
}
|
|
}
|