Fix NullReferenceException caused by Options being undefined. (#2549)

This commit is contained in:
Gediminas Milašius
2023-01-21 12:48:36 +02:00
committed by GitHub
parent 4aded83ab6
commit 02d3ce6e01
2 changed files with 22 additions and 2 deletions

View File

@@ -664,7 +664,9 @@ namespace Discord
if (options == null)
throw new ArgumentNullException(nameof(options), "Options cannot be null!");
if ((Options?.Count ?? 0) + options.Length > SlashCommandBuilder.MaxOptionsCount)
Options ??= new List<SlashCommandOptionBuilder>();
if (Options.Count + options.Length > SlashCommandBuilder.MaxOptionsCount)
throw new ArgumentOutOfRangeException(nameof(options), $"There can only be {SlashCommandBuilder.MaxOptionsCount} options per sub command group!");
foreach (var option in options)