"""Support""" the 'reactions' field on message objects

this is all really broken
This commit is contained in:
Christopher F
2016-10-31 21:00:35 -04:00
parent 838d60e2c2
commit 7018bc9c58
12 changed files with 128 additions and 7 deletions

View File

@@ -18,6 +18,7 @@ namespace Discord.Rest
private ImmutableArray<Attachment> _attachments;
private ImmutableArray<Embed> _embeds;
private ImmutableArray<ITag> _tags;
private ImmutableArray<RestReaction> _reactions;
public override bool IsTTS => _isTTS;
public override bool IsPinned => _isPinned;
@@ -29,6 +30,7 @@ namespace Discord.Rest
public override IReadOnlyCollection<ulong> MentionedRoleIds => MessageHelper.FilterTagsByKey(TagType.RoleMention, _tags);
public override IReadOnlyCollection<RestUser> MentionedUsers => MessageHelper.FilterTagsByValue<RestUser>(TagType.UserMention, _tags);
public override IReadOnlyCollection<ITag> Tags => _tags;
public override IReadOnlyCollection<IReaction> Reactions => _reactions;
internal RestUserMessage(BaseDiscordClient discord, ulong id, IMessageChannel channel, RestUser author, IGuild guild)
: base(discord, id, channel, author, guild)
@@ -103,6 +105,20 @@ namespace Discord.Rest
}
}
if (model.Reactions.IsSpecified)
{
var value = model.Reactions.Value;
if (value.Length > 0)
{
var reactions = ImmutableArray.CreateBuilder<RestReaction>(value.Length);
for (int i = 0; i < value.Length; i++)
reactions.Add(new RestReaction(value[i]));
_reactions = reactions.ToImmutable();
}
else
_reactions = ImmutableArray.Create<RestReaction>();
}
if (model.Content.IsSpecified)
{
var text = model.Content.Value;