Browse Source

Agument error corrections (#149)

* Changed arguments to use the variables for errors

* Changed name to description on error ArgumentException

* Added value?.Length < 1 for Name and Description

* Removed old note and added a paragraph

* change para to <note type="warning"> for Value
pull/1923/head
Simon Hjorthøj GitHub 4 years ago
parent
commit
8f6173e713
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 6 deletions
  1. +3
    -1
      src/Discord.Net.Core/Entities/Interactions/ApplicationCommandOption.cs
  2. +5
    -2
      src/Discord.Net.Core/Entities/Interactions/ApplicationCommandOptionChoice.cs
  3. +3
    -3
      src/Discord.Net.Core/Entities/Interactions/SlashCommandBuilder.cs

+ 3
- 1
src/Discord.Net.Core/Entities/Interactions/ApplicationCommandOption.cs View File

@@ -45,7 +45,9 @@ namespace Discord
set set
{ {
if (value?.Length > 100) if (value?.Length > 100)
throw new ArgumentException("Name length must be less than or equal to 32");
throw new ArgumentException("Description length must be less than or equal to 100");
if (value?.Length < 1)
throw new ArgumentException("Description length must at least 1 character in length");
_description = value; _description = value;
} }
} }


+ 5
- 2
src/Discord.Net.Core/Entities/Interactions/ApplicationCommandOptionChoice.cs View File

@@ -23,14 +23,17 @@ namespace Discord
{ {
if(value?.Length > 100) if(value?.Length > 100)
throw new ArgumentException("Name length must be less than or equal to 100"); throw new ArgumentException("Name length must be less than or equal to 100");
if (value?.Length < 1)
throw new ArgumentException("Name length must at least 1 character in length");
_name = value; _name = value;
} }
} }


// Note: discord allows strings & ints as values. how should that be handled?
// should we make this an object and then just type check it?
/// <summary> /// <summary>
/// The value of this choice. /// The value of this choice.
/// <note type="warning">
/// Discord only accepts int and string as the input.
/// </note>
/// </summary> /// </summary>
public object Value public object Value
{ {


+ 3
- 3
src/Discord.Net.Core/Entities/Interactions/SlashCommandBuilder.cs View File

@@ -296,7 +296,7 @@ namespace Discord
set set
{ {
if (value?.Length > SlashCommandBuilder.MaxNameLength) if (value?.Length > SlashCommandBuilder.MaxNameLength)
throw new ArgumentException("Name length must be less than or equal to 32");
throw new ArgumentException($"Name length must be less than or equal to {SlashCommandBuilder.MaxNameLength}");
if (value?.Length < 1) if (value?.Length < 1)
throw new ArgumentException("Name length must at least 1 characters in length"); throw new ArgumentException("Name length must at least 1 characters in length");


@@ -317,9 +317,9 @@ namespace Discord
set set
{ {
if (value?.Length > SlashCommandBuilder.MaxDescriptionLength) if (value?.Length > SlashCommandBuilder.MaxDescriptionLength)
throw new ArgumentException("Description length must be less than or equal to 100");
throw new ArgumentException($"Description length must be less than or equal to {SlashCommandBuilder.MaxDescriptionLength}");
if (value?.Length < 1) if (value?.Length < 1)
throw new ArgumentException("Name length must at least 1 character in length");
throw new ArgumentException("Description length must at least 1 character in length");


_description = value; _description = value;
} }


Loading…
Cancel
Save