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,
|
||||
};
|
||||
|
||||
|
||||
@@ -204,7 +204,8 @@ namespace Discord.WebSocket
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -152,7 +152,7 @@ namespace Discord.WebSocket
|
||||
{
|
||||
var entity = new SocketGuildUser(guild, guild.Discord.GetOrCreateUser(state, model));
|
||||
entity.Update(state, model);
|
||||
entity.UpdateRoles(new ulong[0]);
|
||||
entity.UpdateRoles([]);
|
||||
return entity;
|
||||
}
|
||||
internal static SocketGuildUser Create(SocketGuild guild, ClientState state, MemberModel model)
|
||||
@@ -160,7 +160,7 @@ namespace Discord.WebSocket
|
||||
var entity = new SocketGuildUser(guild, guild.Discord.GetOrCreateUser(state, model.User));
|
||||
entity.Update(state, model);
|
||||
if (!model.Roles.IsSpecified)
|
||||
entity.UpdateRoles(new ulong[0]);
|
||||
entity.UpdateRoles([]);
|
||||
return entity;
|
||||
}
|
||||
internal static SocketGuildUser Create(SocketGuild guild, ClientState state, PresenceModel model)
|
||||
@@ -168,7 +168,7 @@ namespace Discord.WebSocket
|
||||
var entity = new SocketGuildUser(guild, guild.Discord.GetOrCreateUser(state, model.User));
|
||||
entity.Update(state, model, false);
|
||||
if (!model.Roles.IsSpecified)
|
||||
entity.UpdateRoles(new ulong[0]);
|
||||
entity.UpdateRoles([]);
|
||||
return entity;
|
||||
}
|
||||
internal void Update(ClientState state, MemberModel model)
|
||||
|
||||
Reference in New Issue
Block a user