feature: Add stickers (#1726)
This commit is contained in:
@@ -99,6 +99,8 @@ namespace Discord.WebSocket
|
||||
/// <inheritdoc />
|
||||
public virtual IReadOnlyCollection<ITag> Tags => ImmutableArray.Create<ITag>();
|
||||
/// <inheritdoc />
|
||||
public virtual IReadOnlyCollection<Sticker> Stickers => ImmutableArray.Create<Sticker>();
|
||||
/// <inheritdoc />
|
||||
public IReadOnlyDictionary<IEmote, ReactionMetadata> Reactions => _reactions.GroupBy(r => r.Emote).ToDictionary(x => x.Key, x => new ReactionMetadata { ReactionCount = x.Count(), IsMe = x.Any(y => y.UserId == Discord.CurrentUser.Id) });
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -194,6 +196,8 @@ namespace Discord.WebSocket
|
||||
IReadOnlyCollection<ulong> IMessage.MentionedRoleIds => MentionedRoles.Select(x => x.Id).ToImmutableArray();
|
||||
/// <inheritdoc />
|
||||
IReadOnlyCollection<ulong> IMessage.MentionedUserIds => MentionedUsers.Select(x => x.Id).ToImmutableArray();
|
||||
/// <inheritdoc />
|
||||
IReadOnlyCollection<ISticker> IMessage.Stickers => Stickers;
|
||||
|
||||
internal void AddReaction(SocketReaction reaction)
|
||||
{
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace Discord.WebSocket
|
||||
private ImmutableArray<ITag> _tags = ImmutableArray.Create<ITag>();
|
||||
private ImmutableArray<SocketRole> _roleMentions = ImmutableArray.Create<SocketRole>();
|
||||
private ImmutableArray<SocketUser> _userMentions = ImmutableArray.Create<SocketUser>();
|
||||
private ImmutableArray<Sticker> _stickers = ImmutableArray.Create<Sticker>();
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool IsTTS => _isTTS;
|
||||
@@ -47,6 +48,8 @@ namespace Discord.WebSocket
|
||||
/// <inheritdoc />
|
||||
public override IReadOnlyCollection<SocketUser> MentionedUsers => _userMentions;
|
||||
/// <inheritdoc />
|
||||
public override IReadOnlyCollection<Sticker> Stickers => _stickers;
|
||||
/// <inheritdoc />
|
||||
public IUserMessage ReferencedMessage => _referencedMessage;
|
||||
|
||||
internal SocketUserMessage(DiscordSocketClient discord, ulong id, ISocketMessageChannel channel, SocketUser author, MessageSource source)
|
||||
@@ -158,6 +161,20 @@ namespace Discord.WebSocket
|
||||
refMsgAuthor = new SocketUnknownUser(Discord, id: 0);
|
||||
_referencedMessage = SocketUserMessage.Create(Discord, state, refMsgAuthor, Channel, refMsg);
|
||||
}
|
||||
|
||||
if (model.Stickers.IsSpecified)
|
||||
{
|
||||
var value = model.Stickers.Value;
|
||||
if (value.Length > 0)
|
||||
{
|
||||
var stickers = ImmutableArray.CreateBuilder<Sticker>(value.Length);
|
||||
for (int i = 0; i < value.Length; i++)
|
||||
stickers.Add(Sticker.Create(value[i]));
|
||||
_stickers = stickers.ToImmutable();
|
||||
}
|
||||
else
|
||||
_stickers = ImmutableArray.Create<Sticker>();
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
Reference in New Issue
Block a user