Fix Ids in ActionRowComponent and SelectmenuComponent (#3122)

This commit is contained in:
Mihail Gribkov
2025-05-09 19:19:21 +03:00
committed by GitHub
parent 4ab96c7721
commit 57cdec70bf
3 changed files with 4 additions and 2 deletions

View File

@@ -26,9 +26,10 @@ public class ActionRowComponent : IMessageComponent
internal ActionRowComponent() { }
internal ActionRowComponent(IReadOnlyCollection<IMessageComponent> components)
internal ActionRowComponent(IReadOnlyCollection<IMessageComponent> components, int? id)
{
Components = components;
Id = id;
}
/// <inheritdoc />

View File

@@ -200,7 +200,7 @@ public class ActionRowBuilder : IMessageComponentBuilder, IInteractableComponent
Preconditions.AtLeast(Components.Count, 1, nameof(Components), "There must be at least 1 component in a row.");
Preconditions.AtMost(Components.Count, MaxChildCount, nameof(Components), $"Action row can only contain {MaxChildCount} child components!");
return new ActionRowComponent(_components.Select(x => x.Build()).ToList());
return new ActionRowComponent(_components.Select(x => x.Build()).ToList(), Id);
}
IMessageComponent IMessageComponentBuilder.Build() => Build();

View File

@@ -54,6 +54,7 @@ namespace Discord.API
Disabled = component.IsDisabled;
ChannelTypes = component.ChannelTypes.ToArray();
DefaultValues = component.DefaultValues.Select(x => new SelectMenuDefaultValue {Id = x.Id, Type = x.Type}).ToArray();
Id = component.Id ?? Optional<int>.Unspecified;
}
[JsonIgnore]