[abibrk] change: Update ISystemMessage interface to allow reactions (#1368)
* Move reaction methods of IUserMessage to IReactionMessage Moves the reaction-related methods contained in IUserMessage to the IReactionMessage type. Updates the type of ISystemMessage so that it implements IReactionMessage. * Move rest reaction implementation to RestReactionMessage Copies the reaction implementation from RestUserMessage to RestReactionMessage. Updates RestUserMessage and RestSystemMessage to be derived from RestReactionMessage instead of RestMessage. * Move WS reaction implementation to SocketReactionMessage Copies the reaction implementation from SocketUserMessage into SocketReactionMessage. Updates SocketSystemMessage and SocketUserMessage to use SocketReactionMessage as the base class. * docs: update summary for ReactionMessage classes * Remove ReactionMessage types, move reaction impl to IMessage Removes the IReactionMessage and derived types, which was unnecessary since all classes derived from IReactionMessage were IMessage. Moves the reaction implementation to IMessage and derived types.
This commit is contained in:
committed by
Christopher F
parent
dcd9cdd13e
commit
07f4d5f353
@@ -2,7 +2,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Model = Discord.API.Message;
|
||||
|
||||
@@ -19,7 +18,6 @@ namespace Discord.Rest
|
||||
private ImmutableArray<Attachment> _attachments = ImmutableArray.Create<Attachment>();
|
||||
private ImmutableArray<Embed> _embeds = ImmutableArray.Create<Embed>();
|
||||
private ImmutableArray<ITag> _tags = ImmutableArray.Create<ITag>();
|
||||
private ImmutableArray<RestReaction> _reactions = ImmutableArray.Create<RestReaction>();
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool IsTTS => _isTTS;
|
||||
@@ -41,8 +39,6 @@ namespace Discord.Rest
|
||||
public override IReadOnlyCollection<RestUser> MentionedUsers => MessageHelper.FilterTagsByValue<RestUser>(TagType.UserMention, _tags);
|
||||
/// <inheritdoc />
|
||||
public override IReadOnlyCollection<ITag> Tags => _tags;
|
||||
/// <inheritdoc />
|
||||
public IReadOnlyDictionary<IEmote, ReactionMetadata> Reactions => _reactions.ToDictionary(x => x.Emote, x => new ReactionMetadata { ReactionCount = x.Count, IsMe = x.Me });
|
||||
|
||||
internal RestUserMessage(BaseDiscordClient discord, ulong id, IMessageChannel channel, IUser author, MessageSource source)
|
||||
: base(discord, id, channel, author, source)
|
||||
@@ -117,22 +113,6 @@ 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(RestReaction.Create(value[i]));
|
||||
_reactions = reactions.ToImmutable();
|
||||
}
|
||||
else
|
||||
_reactions = ImmutableArray.Create<RestReaction>();
|
||||
}
|
||||
else
|
||||
_reactions = ImmutableArray.Create<RestReaction>();
|
||||
|
||||
if (model.Content.IsSpecified)
|
||||
{
|
||||
var text = model.Content.Value;
|
||||
@@ -150,22 +130,6 @@ namespace Discord.Rest
|
||||
Update(model);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task AddReactionAsync(IEmote emote, RequestOptions options = null)
|
||||
=> MessageHelper.AddReactionAsync(this, emote, Discord, options);
|
||||
/// <inheritdoc />
|
||||
public Task RemoveReactionAsync(IEmote emote, IUser user, RequestOptions options = null)
|
||||
=> MessageHelper.RemoveReactionAsync(this, user.Id, emote, Discord, options);
|
||||
/// <inheritdoc />
|
||||
public Task RemoveReactionAsync(IEmote emote, ulong userId, RequestOptions options = null)
|
||||
=> MessageHelper.RemoveReactionAsync(this, userId, emote, Discord, options);
|
||||
/// <inheritdoc />
|
||||
public Task RemoveAllReactionsAsync(RequestOptions options = null)
|
||||
=> MessageHelper.RemoveAllReactionsAsync(this, Discord, options);
|
||||
/// <inheritdoc />
|
||||
public IAsyncEnumerable<IReadOnlyCollection<IUser>> GetReactionUsersAsync(IEmote emote, int limit, RequestOptions options = null)
|
||||
=> MessageHelper.GetReactionUsersAsync(this, emote, limit, Discord, options);
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task PinAsync(RequestOptions options = null)
|
||||
=> MessageHelper.PinAsync(this, Discord, options);
|
||||
|
||||
Reference in New Issue
Block a user