Browse Source

Whoops missed a few (#142)

pull/1923/head
Simon Hjorthøj GitHub 3 years ago
parent
commit
7e36fbc7c1
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 9 deletions
  1. +9
    -9
      src/Discord.Net.Core/Entities/Interactions/SlashCommandBuilder.cs

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

@@ -37,12 +37,12 @@ namespace Discord
set set
{ {
Preconditions.NotNullOrEmpty(value, nameof(Name)); Preconditions.NotNullOrEmpty(value, nameof(Name));
Preconditions.AtLeast(value.Length, 3, nameof(Name));
Preconditions.AtLeast(value.Length, 1, nameof(Name));
Preconditions.AtMost(value.Length, MaxNameLength, nameof(Name)); Preconditions.AtMost(value.Length, MaxNameLength, nameof(Name));


// Discord updated the docs, this regex prevents special characters like @!$%(... etc, // Discord updated the docs, this regex prevents special characters like @!$%(... etc,
// https://discord.com/developers/docs/interactions/slash-commands#applicationcommand // https://discord.com/developers/docs/interactions/slash-commands#applicationcommand
if (!Regex.IsMatch(value, @"^[\w-]{3,32}$"))
if (!Regex.IsMatch(value, @"^[\w-]{1,32}$"))
throw new ArgumentException("Command name cannot contain any special characters or whitespaces!"); throw new ArgumentException("Command name cannot contain any special characters or whitespaces!");


_name = value; _name = value;
@@ -169,17 +169,17 @@ namespace Discord
{ {
// Make sure the name matches the requirements from discord // Make sure the name matches the requirements from discord
Preconditions.NotNullOrEmpty(name, nameof(name)); Preconditions.NotNullOrEmpty(name, nameof(name));
Preconditions.AtLeast(name.Length, 3, nameof(name));
Preconditions.AtLeast(name.Length, 1, nameof(name));
Preconditions.AtMost(name.Length, MaxNameLength, nameof(name)); Preconditions.AtMost(name.Length, MaxNameLength, nameof(name));


// Discord updated the docs, this regex prevents special characters like @!$%( and s p a c e s.. etc, // Discord updated the docs, this regex prevents special characters like @!$%( and s p a c e s.. etc,
// https://discord.com/developers/docs/interactions/slash-commands#applicationcommand // https://discord.com/developers/docs/interactions/slash-commands#applicationcommand
if (!Regex.IsMatch(name, @"^[\w-]{3,32}$"))
if (!Regex.IsMatch(name, @"^[\w-]{1,32}$"))
throw new ArgumentException("Command name cannot contian any special characters or whitespaces!", nameof(name)); throw new ArgumentException("Command name cannot contian any special characters or whitespaces!", nameof(name));


// same with description // same with description
Preconditions.NotNullOrEmpty(description, nameof(description)); Preconditions.NotNullOrEmpty(description, nameof(description));
Preconditions.AtLeast(description.Length, 3, nameof(description));
Preconditions.AtLeast(description.Length, 1, nameof(description));
Preconditions.AtMost(description.Length, MaxDescriptionLength, nameof(description)); Preconditions.AtMost(description.Length, MaxDescriptionLength, nameof(description));


// make sure theres only one option with default set to true // make sure theres only one option with default set to true
@@ -301,7 +301,7 @@ namespace Discord
throw new ArgumentException("Name length must at least 1 characters in length"); throw new ArgumentException("Name length must at least 1 characters in length");


if (value != null) if (value != null)
if (!Regex.IsMatch(value, @"^[\w-]{3,32}$"))
if (!Regex.IsMatch(value, @"^[\w-]{1,32}$"))
throw new ArgumentException("Option name cannot contian any special characters or whitespaces!"); throw new ArgumentException("Option name cannot contian any special characters or whitespaces!");


_name = value; _name = value;
@@ -392,17 +392,17 @@ namespace Discord
{ {
// Make sure the name matches the requirements from discord // Make sure the name matches the requirements from discord
Preconditions.NotNullOrEmpty(name, nameof(name)); Preconditions.NotNullOrEmpty(name, nameof(name));
Preconditions.AtLeast(name.Length, 3, nameof(name));
Preconditions.AtLeast(name.Length, 1, nameof(name));
Preconditions.AtMost(name.Length, SlashCommandBuilder.MaxNameLength, nameof(name)); Preconditions.AtMost(name.Length, SlashCommandBuilder.MaxNameLength, nameof(name));


// Discord updated the docs, this regex prevents special characters like @!$%( and s p a c e s.. etc, // Discord updated the docs, this regex prevents special characters like @!$%( and s p a c e s.. etc,
// https://discord.com/developers/docs/interactions/slash-commands#applicationcommand // https://discord.com/developers/docs/interactions/slash-commands#applicationcommand
if (!Regex.IsMatch(name, @"^[\w-]{3,32}$"))
if (!Regex.IsMatch(name, @"^[\w-]{1,32}$"))
throw new ArgumentException("Command name cannot contian any special characters or whitespaces!", nameof(name)); throw new ArgumentException("Command name cannot contian any special characters or whitespaces!", nameof(name));


// same with description // same with description
Preconditions.NotNullOrEmpty(description, nameof(description)); Preconditions.NotNullOrEmpty(description, nameof(description));
Preconditions.AtLeast(description.Length, 3, nameof(description));
Preconditions.AtLeast(description.Length, 1, nameof(description));
Preconditions.AtMost(description.Length, SlashCommandBuilder.MaxDescriptionLength, nameof(description)); Preconditions.AtMost(description.Length, SlashCommandBuilder.MaxDescriptionLength, nameof(description));


// make sure theres only one option with default set to true // make sure theres only one option with default set to true


Loading…
Cancel
Save