@@ -164,6 +164,10 @@ namespace Discord | |||||
/// </summary> | /// </summary> | ||||
IReadOnlyDictionary<IEmote, ReactionMetadata> Reactions { get; } | IReadOnlyDictionary<IEmote, ReactionMetadata> Reactions { get; } | ||||
/// <summary> | |||||
/// The <see cref="IMessageComponent"/>'s attached to this message | |||||
/// </summary> | |||||
IReadOnlyCollection<IMessageComponent> Components { get; } | |||||
/// <summary> | /// <summary> | ||||
/// Adds a reaction to this message. | /// Adds a reaction to this message. | ||||
/// </summary> | /// </summary> | ||||
@@ -58,5 +58,7 @@ namespace Discord.API | |||||
public Optional<AllowedMentions> AllowedMentions { get; set; } | public Optional<AllowedMentions> AllowedMentions { get; set; } | ||||
[JsonProperty("referenced_message")] | [JsonProperty("referenced_message")] | ||||
public Optional<Message> ReferencedMessage { get; set; } | public Optional<Message> ReferencedMessage { get; set; } | ||||
[JsonProperty("components")] | |||||
public Optional<IMessageComponent[]> Components { get; set; } | |||||
} | } | ||||
} | } |
@@ -68,6 +68,9 @@ namespace Discord.Rest | |||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public MessageReference Reference { get; private set; } | public MessageReference Reference { get; private set; } | ||||
/// <inheritdoc/> | |||||
public IReadOnlyCollection<ActionRowComponent> Components { get; private set; } | |||||
internal RestMessage(BaseDiscordClient discord, ulong id, IMessageChannel channel, IUser author, MessageSource source) | internal RestMessage(BaseDiscordClient discord, ulong id, IMessageChannel channel, IUser author, MessageSource source) | ||||
: base(discord, id) | : base(discord, id) | ||||
{ | { | ||||
@@ -113,7 +116,7 @@ namespace Discord.Rest | |||||
}; | }; | ||||
} | } | ||||
if(model.Reference.IsSpecified) | |||||
if (model.Reference.IsSpecified) | |||||
{ | { | ||||
// Creates a new Reference from the API model | // Creates a new Reference from the API model | ||||
Reference = new MessageReference | Reference = new MessageReference | ||||
@@ -124,6 +127,15 @@ namespace Discord.Rest | |||||
}; | }; | ||||
} | } | ||||
if (model.Components.IsSpecified) | |||||
{ | |||||
Components = model.Components.Value.Select(x => | |||||
(x as Newtonsoft.Json.Linq.JToken).ToObject<ActionRowComponent>() | |||||
).ToList(); | |||||
} | |||||
else | |||||
Components = new List<ActionRowComponent>(); | |||||
if (model.Reactions.IsSpecified) | if (model.Reactions.IsSpecified) | ||||
{ | { | ||||
var value = model.Reactions.Value; | var value = model.Reactions.Value; | ||||
@@ -168,7 +180,8 @@ namespace Discord.Rest | |||||
IReadOnlyCollection<IEmbed> IMessage.Embeds => Embeds; | IReadOnlyCollection<IEmbed> IMessage.Embeds => Embeds; | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
IReadOnlyCollection<ulong> IMessage.MentionedUserIds => MentionedUsers.Select(x => x.Id).ToImmutableArray(); | IReadOnlyCollection<ulong> IMessage.MentionedUserIds => MentionedUsers.Select(x => x.Id).ToImmutableArray(); | ||||
/// <inheritdoc/> | |||||
IReadOnlyCollection<IMessageComponent> IMessage.Components => Components; | |||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public IReadOnlyDictionary<IEmote, ReactionMetadata> Reactions => _reactions.ToDictionary(x => x.Emote, x => new ReactionMetadata { ReactionCount = x.Count, IsMe = x.Me }); | public IReadOnlyDictionary<IEmote, ReactionMetadata> Reactions => _reactions.ToDictionary(x => x.Emote, x => new ReactionMetadata { ReactionCount = x.Count, IsMe = x.Me }); | ||||
@@ -58,6 +58,9 @@ namespace Discord.WebSocket | |||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public MessageReference Reference { get; private set; } | public MessageReference Reference { get; private set; } | ||||
/// <inheritdoc/> | |||||
public IReadOnlyCollection<ActionRowComponent> Components { get; private set; } | |||||
/// <summary> | /// <summary> | ||||
/// Returns all attachments included in this message. | /// Returns all attachments included in this message. | ||||
/// </summary> | /// </summary> | ||||
@@ -156,6 +159,15 @@ namespace Discord.WebSocket | |||||
MessageId = model.Reference.Value.MessageId | MessageId = model.Reference.Value.MessageId | ||||
}; | }; | ||||
} | } | ||||
if (model.Components.IsSpecified) | |||||
{ | |||||
Components = model.Components.Value.Select(x => | |||||
(x as Newtonsoft.Json.Linq.JToken).ToObject<ActionRowComponent>() | |||||
).ToList(); | |||||
} | |||||
else | |||||
Components = new List<ActionRowComponent>(); | |||||
} | } | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
@@ -188,7 +200,8 @@ namespace Discord.WebSocket | |||||
IReadOnlyCollection<ulong> IMessage.MentionedRoleIds => MentionedRoles.Select(x => x.Id).ToImmutableArray(); | IReadOnlyCollection<ulong> IMessage.MentionedRoleIds => MentionedRoles.Select(x => x.Id).ToImmutableArray(); | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
IReadOnlyCollection<ulong> IMessage.MentionedUserIds => MentionedUsers.Select(x => x.Id).ToImmutableArray(); | IReadOnlyCollection<ulong> IMessage.MentionedUserIds => MentionedUsers.Select(x => x.Id).ToImmutableArray(); | ||||
/// <inheritdoc/> | |||||
IReadOnlyCollection<IMessageComponent> IMessage.Components => Components; | |||||
internal void AddReaction(SocketReaction reaction) | internal void AddReaction(SocketReaction reaction) | ||||
{ | { | ||||
_reactions.Add(reaction); | _reactions.Add(reaction); | ||||