diff --git a/src/Discord.Net.Core/Entities/Interactions/SlashCommands/SlashCommandBuilder.cs b/src/Discord.Net.Core/Entities/Interactions/SlashCommands/SlashCommandBuilder.cs index bf74a160c..d7d086762 100644 --- a/src/Discord.Net.Core/Entities/Interactions/SlashCommands/SlashCommandBuilder.cs +++ b/src/Discord.Net.Core/Entities/Interactions/SlashCommands/SlashCommandBuilder.cs @@ -255,9 +255,6 @@ namespace Discord if (options == null) throw new ArgumentNullException(nameof(options), "Options cannot be null!"); - if (options.Length == 0) - throw new ArgumentException("Options cannot be empty!", nameof(options)); - Options ??= new List(); if (Options.Count + options.Length > MaxOptionsCount) @@ -409,7 +406,7 @@ namespace Discord MinValue = MinValue, MaxValue = MaxValue }; - } + } /// /// Adds an option to the current slash command. @@ -477,6 +474,26 @@ namespace Discord return this; } + /// + /// Adds a collection of options to the current option. + /// + /// The collection of options to add. + /// The current builder. + public SlashCommandOptionBuilder AddOptions(params SlashCommandOptionBuilder[] options) + { + if (options == null) + throw new ArgumentNullException(nameof(options), "Options cannot be null!"); + + if ((Options?.Count ?? 0) + 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) + Preconditions.Options(option.Name, option.Description); + + Options.AddRange(options); + return this; + } + /// /// Adds a choice to the current option. /// @@ -640,7 +657,7 @@ namespace Discord MinValue = value; return this; } - + /// /// Sets the current builders max value field. ///