minor optimization + make sure top level components are action rows (#2991)
This commit is contained in:
@@ -82,7 +82,7 @@ internal class Message
|
||||
public Optional<Message> ReferencedMessage { get; set; }
|
||||
|
||||
[JsonProperty("components")]
|
||||
public Optional<ActionRowComponent[]> Components { get; set; }
|
||||
public Optional<IMessageComponent[]> Components { get; set; }
|
||||
|
||||
[JsonProperty("interaction")]
|
||||
public Optional<MessageInteraction> Interaction { get; set; }
|
||||
|
||||
@@ -171,7 +171,8 @@ namespace Discord.Rest
|
||||
|
||||
if (model.Components.IsSpecified)
|
||||
{
|
||||
Components = model.Components.Value.Select(x => new ActionRowComponent(x.Components.Select<IMessageComponent, IMessageComponent>(y =>
|
||||
Components = model.Components.Value.Where(x => x.Type is ComponentType.ActionRow)
|
||||
.Select(x => new ActionRowComponent(((API.ActionRowComponent)x).Components.Select<IMessageComponent, IMessageComponent>(y =>
|
||||
{
|
||||
switch (y.Type)
|
||||
{
|
||||
|
||||
@@ -198,7 +198,7 @@ namespace Discord.Rest
|
||||
Content = (data.Content.IsSpecified && data.Content.Value == null) ? Optional<string>.Unspecified : data.Content,
|
||||
Embeds = data.Embeds,
|
||||
AllowedMentions = data.AllowedMentions,
|
||||
Components = data.Components,
|
||||
Components = data.Components.GetValueOrDefault(Array.Empty<API.ActionRowComponent>()),
|
||||
Flags = data.Flags,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user