@@ -2,7 +2,6 @@ using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using System.Threading.Tasks;
using Model = Discord.API.Message;
using Model = Discord.API.Message;
@@ -12,14 +11,13 @@ namespace Discord.Rest
/// Represents a REST-based message sent by a user.
/// Represents a REST-based message sent by a user.
/// </summary>
/// </summary>
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
public class RestUserMessage : RestMessage, IUserMessage
public class RestUserMessage : RestReaction Message, IUserMessage
{
{
private bool _isMentioningEveryone, _isTTS, _isPinned, _isSuppressed;
private bool _isMentioningEveryone, _isTTS, _isPinned, _isSuppressed;
private long? _editedTimestampTicks;
private long? _editedTimestampTicks;
private ImmutableArray<Attachment> _attachments = ImmutableArray.Create<Attachment>();
private ImmutableArray<Attachment> _attachments = ImmutableArray.Create<Attachment>();
private ImmutableArray<Embed> _embeds = ImmutableArray.Create<Embed>();
private ImmutableArray<Embed> _embeds = ImmutableArray.Create<Embed>();
private ImmutableArray<ITag> _tags = ImmutableArray.Create<ITag>();
private ImmutableArray<ITag> _tags = ImmutableArray.Create<ITag>();
private ImmutableArray<RestReaction> _reactions = ImmutableArray.Create<RestReaction>();
/// <inheritdoc />
/// <inheritdoc />
public override bool IsTTS => _isTTS;
public override bool IsTTS => _isTTS;
@@ -41,8 +39,6 @@ namespace Discord.Rest
public override IReadOnlyCollection<RestUser> MentionedUsers => MessageHelper.FilterTagsByValue<RestUser>(TagType.UserMention, _tags);
public override IReadOnlyCollection<RestUser> MentionedUsers => MessageHelper.FilterTagsByValue<RestUser>(TagType.UserMention, _tags);
/// <inheritdoc />
/// <inheritdoc />
public override IReadOnlyCollection<ITag> Tags => _tags;
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)
internal RestUserMessage(BaseDiscordClient discord, ulong id, IMessageChannel channel, IUser author, MessageSource source)
: base(discord, id, channel, author, 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)
if (model.Content.IsSpecified)
{
{
var text = model.Content.Value;
var text = model.Content.Value;
@@ -150,22 +130,6 @@ namespace Discord.Rest
Update(model);
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 />
/// <inheritdoc />
public Task PinAsync(RequestOptions options = null)
public Task PinAsync(RequestOptions options = null)
=> MessageHelper.PinAsync(this, Discord, options);
=> MessageHelper.PinAsync(this, Discord, options);