Refactor, rearrange, reimplement reactions; receive over gateway

This commit is contained in:
Christopher F
2016-11-05 18:15:47 -04:00
parent 7018bc9c58
commit e2e2c4308d
15 changed files with 96 additions and 41 deletions

View File

@@ -27,7 +27,6 @@ namespace Discord.Rest
public virtual IReadOnlyCollection<ulong> MentionedRoleIds => ImmutableArray.Create<ulong>();
public virtual IReadOnlyCollection<RestUser> MentionedUsers => ImmutableArray.Create<RestUser>();
public virtual IReadOnlyCollection<ITag> Tags => ImmutableArray.Create<ITag>();
public virtual IReadOnlyCollection<IReaction> Reactions => ImmutableArray.Create<RestReaction>();
public virtual ulong? WebhookId => null;
public bool IsWebhook => WebhookId != null;
@@ -71,6 +70,5 @@ namespace Discord.Rest
IReadOnlyCollection<IAttachment> IMessage.Attachments => Attachments;
IReadOnlyCollection<IEmbed> IMessage.Embeds => Embeds;
IReadOnlyCollection<ulong> IMessage.MentionedUserIds => MentionedUsers.Select(x => x.Id).ToImmutableArray();
IReadOnlyCollection<IReaction> IMessage.Reactions => Reactions;
}
}

View File

@@ -10,17 +10,13 @@ namespace Discord
{
internal RestReaction(Model model)
{
_emoji = model.Emoji;
_count = model.Count;
Emoji = Emoji.FromApi(model.Emoji);
Count = model.Count;
Me = model.Me;
}
internal readonly API.Emoji _emoji;
internal readonly int _count;
internal readonly bool _me;
public API.Emoji Emoji => _emoji;
public int Count => _count;
public bool Me => _me;
public Emoji Emoji { get; private set; }
public int Count { get; private set; }
public bool Me { get; private set; }
}
}

View File

@@ -30,7 +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;
public IReadOnlyDictionary<Emoji, int> Reactions => _reactions.ToDictionary(x => x.Emoji, x => x.Count);
internal RestUserMessage(BaseDiscordClient discord, ulong id, IMessageChannel channel, RestUser author, IGuild guild)
: base(discord, id, channel, author, guild)