Fix null error when using a SelectMenuBuilder constructor (#2924)
* Fix null error when using a `SelectMenuBuilder` constructor * Update references to `Options` to support `null`
This commit is contained in:
@@ -77,7 +77,7 @@ namespace Discord
|
||||
AddComponent(cmp, row);
|
||||
break;
|
||||
case SelectMenuComponent menu:
|
||||
WithSelectMenu(menu.CustomId, menu.Options.Select(x => new SelectMenuOptionBuilder(x.Label, x.Value, x.Description, x.Emote, x.IsDefault)).ToList(), menu.Placeholder, menu.MinValues, menu.MaxValues, menu.IsDisabled, row);
|
||||
WithSelectMenu(menu.CustomId, menu.Options?.Select(x => new SelectMenuOptionBuilder(x.Label, x.Value, x.Description, x.Emote, x.IsDefault)).ToList(), menu.Placeholder, menu.MinValues, menu.MaxValues, menu.IsDisabled, row);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1040,6 +1040,8 @@ namespace Discord
|
||||
/// </returns>
|
||||
public SelectMenuBuilder AddOption(SelectMenuOptionBuilder option)
|
||||
{
|
||||
Options ??= new();
|
||||
|
||||
if (Options.Count >= MaxOptionCount)
|
||||
throw new InvalidOperationException($"Options count reached {MaxOptionCount}.");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user