@@ -14,7 +14,7 @@ namespace Discord | |||||
Task UnpinAsync(RequestOptions options = null); | Task UnpinAsync(RequestOptions options = null); | ||||
/// <summary> Returns all reactions included in this message. </summary> | /// <summary> Returns all reactions included in this message. </summary> | ||||
IReadOnlyDictionary<Emoji, int> Reactions { get; } | |||||
IReadOnlyDictionary<Emoji, ReactionMetadata> Reactions { get; } | |||||
/// <summary> Adds a reaction to this message. </summary> | /// <summary> Adds a reaction to this message. </summary> | ||||
Task AddReactionAsync(Emoji emoji, RequestOptions options = null); | Task AddReactionAsync(Emoji emoji, RequestOptions options = null); | ||||
@@ -0,0 +1,11 @@ | |||||
namespace Discord | |||||
{ | |||||
public struct ReactionMetadata | |||||
{ | |||||
/// <summary> Gets the number of reactions </summary> | |||||
public int ReactionCount { get; internal set; } | |||||
/// <summary> Returns true if the current user has used this reaction </summary> | |||||
public bool IsMe { get; internal set; } | |||||
} | |||||
} |
@@ -29,7 +29,7 @@ namespace Discord.Rest | |||||
public override IReadOnlyCollection<ulong> MentionedRoleIds => MessageHelper.FilterTagsByKey(TagType.RoleMention, _tags); | public override IReadOnlyCollection<ulong> MentionedRoleIds => MessageHelper.FilterTagsByKey(TagType.RoleMention, _tags); | ||||
public override IReadOnlyCollection<RestUser> MentionedUsers => MessageHelper.FilterTagsByValue<RestUser>(TagType.UserMention, _tags); | public override IReadOnlyCollection<RestUser> MentionedUsers => MessageHelper.FilterTagsByValue<RestUser>(TagType.UserMention, _tags); | ||||
public override IReadOnlyCollection<ITag> Tags => _tags; | public override IReadOnlyCollection<ITag> Tags => _tags; | ||||
public IReadOnlyDictionary<Emoji, int> Reactions => _reactions.ToDictionary(x => x.Emoji, x => x.Count); | |||||
public IReadOnlyDictionary<Emoji, ReactionMetadata> Reactions => _reactions.ToDictionary(x => x.Emoji, x => new ReactionMetadata { ReactionCount = x.Count, IsMe = x.Me }); | |||||
internal RestUserMessage(BaseDiscordClient discord, ulong id, IMessageChannel channel, IUser author) | internal RestUserMessage(BaseDiscordClient discord, ulong id, IMessageChannel channel, IUser author) | ||||
: base(discord, id, channel, author) | : base(discord, id, channel, author) | ||||
@@ -29,7 +29,7 @@ namespace Discord.Rpc | |||||
public override IReadOnlyCollection<ulong> MentionedRoleIds => MessageHelper.FilterTagsByKey(TagType.RoleMention, _tags); | public override IReadOnlyCollection<ulong> MentionedRoleIds => MessageHelper.FilterTagsByKey(TagType.RoleMention, _tags); | ||||
public override IReadOnlyCollection<ulong> MentionedUserIds => MessageHelper.FilterTagsByKey(TagType.UserMention, _tags); | public override IReadOnlyCollection<ulong> MentionedUserIds => MessageHelper.FilterTagsByKey(TagType.UserMention, _tags); | ||||
public override IReadOnlyCollection<ITag> Tags => _tags; | public override IReadOnlyCollection<ITag> Tags => _tags; | ||||
public IReadOnlyDictionary<Emoji, int> Reactions => ImmutableDictionary.Create<Emoji, int>(); | |||||
public IReadOnlyDictionary<Emoji, ReactionMetadata> Reactions => ImmutableDictionary.Create<Emoji, ReactionMetadata>(); | |||||
internal RpcUserMessage(DiscordRpcClient discord, ulong id, RestVirtualMessageChannel channel, RpcUser author) | internal RpcUserMessage(DiscordRpcClient discord, ulong id, RestVirtualMessageChannel channel, RpcUser author) | ||||
: base(discord, id, channel, author) | : base(discord, id, channel, author) | ||||
@@ -30,7 +30,7 @@ namespace Discord.WebSocket | |||||
public override IReadOnlyCollection<SocketGuildChannel> MentionedChannels => MessageHelper.FilterTagsByValue<SocketGuildChannel>(TagType.ChannelMention, _tags); | public override IReadOnlyCollection<SocketGuildChannel> MentionedChannels => MessageHelper.FilterTagsByValue<SocketGuildChannel>(TagType.ChannelMention, _tags); | ||||
public override IReadOnlyCollection<SocketRole> MentionedRoles => MessageHelper.FilterTagsByValue<SocketRole>(TagType.RoleMention, _tags); | public override IReadOnlyCollection<SocketRole> MentionedRoles => MessageHelper.FilterTagsByValue<SocketRole>(TagType.RoleMention, _tags); | ||||
public override IReadOnlyCollection<SocketUser> MentionedUsers => MessageHelper.FilterTagsByValue<SocketUser>(TagType.UserMention, _tags); | public override IReadOnlyCollection<SocketUser> MentionedUsers => MessageHelper.FilterTagsByValue<SocketUser>(TagType.UserMention, _tags); | ||||
public IReadOnlyDictionary<Emoji, int> Reactions => _reactions.GroupBy(r => r.Emoji).ToDictionary(x => x.Key, x => x.Count()); | |||||
public IReadOnlyDictionary<Emoji, ReactionMetadata> Reactions => _reactions.GroupBy(r => r.Emoji).ToDictionary(x => x.Key, x => new ReactionMetadata { ReactionCount = x.Count(), IsMe = x.Any(y => y.UserId == Discord.CurrentUser.Id) }); | |||||
internal SocketUserMessage(DiscordSocketClient discord, ulong id, ISocketMessageChannel channel, SocketUser author) | internal SocketUserMessage(DiscordSocketClient discord, ulong id, ISocketMessageChannel channel, SocketUser author) | ||||
: base(discord, id, channel, author) | : base(discord, id, channel, author) | ||||