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:
Christoph L
2022-04-28 13:49:38 +02:00
committed by GitHub
parent f5dbb95610
commit 0554ac2442
2 changed files with 25 additions and 19 deletions

View File

@@ -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
}
}