fix: Guarding against empty descriptions in SlashCommandBuilder/SlashCommandOptionBuilder (#2260)
* adding null/empty check for option-descriptions * moving check to Preconditions * docs
This commit is contained in:
@@ -297,5 +297,22 @@ namespace Discord
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SlashCommandOptions
|
||||
|
||||
/// <exception cref="ArgumentNullException"><paramref name="description"/> or <paramref name="name"/> is null.</exception>
|
||||
/// <exception cref="ArgumentException"><paramref name="description"/> or <paramref name="name"/> are either empty or their length exceed limits.</exception>
|
||||
public static void Options(string name, string description)
|
||||
{
|
||||
// Make sure the name matches the requirements from discord
|
||||
NotNullOrEmpty(name, nameof(name));
|
||||
NotNullOrEmpty(description, nameof(description));
|
||||
AtLeast(name.Length, 1, nameof(name));
|
||||
AtMost(name.Length, SlashCommandBuilder.MaxNameLength, nameof(name));
|
||||
AtLeast(description.Length, 1, nameof(description));
|
||||
AtMost(description.Length, SlashCommandBuilder.MaxDescriptionLength, nameof(description));
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user