feat: AddOptions no longer has an uneeded restriction, added AddOptions to SlashCommandOptionBuilder (#2338)
This commit is contained in:
committed by
GitHub
parent
b50afd7d8d
commit
3a37f8914c
@@ -255,9 +255,6 @@ namespace Discord
|
|||||||
if (options == null)
|
if (options == null)
|
||||||
throw new ArgumentNullException(nameof(options), "Options cannot be 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<SlashCommandOptionBuilder>();
|
Options ??= new List<SlashCommandOptionBuilder>();
|
||||||
|
|
||||||
if (Options.Count + options.Length > MaxOptionsCount)
|
if (Options.Count + options.Length > MaxOptionsCount)
|
||||||
@@ -409,7 +406,7 @@ namespace Discord
|
|||||||
MinValue = MinValue,
|
MinValue = MinValue,
|
||||||
MaxValue = MaxValue
|
MaxValue = MaxValue
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adds an option to the current slash command.
|
/// Adds an option to the current slash command.
|
||||||
@@ -477,6 +474,26 @@ namespace Discord
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds a collection of options to the current option.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="options">The collection of options to add.</param>
|
||||||
|
/// <returns>The current builder.</returns>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adds a choice to the current option.
|
/// Adds a choice to the current option.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -640,7 +657,7 @@ namespace Discord
|
|||||||
MinValue = value;
|
MinValue = value;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sets the current builders max value field.
|
/// Sets the current builders max value field.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user