Browse Source

Add uppercase character check to SlashCommandBuilder and ApplicationCommandOptionProperties (#339)

pull/1958/head
Cenk Ergen GitHub 3 years ago
parent
commit
87bce990d9
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 0 deletions
  1. +4
    -0
      src/Discord.Net.Core/Entities/Interactions/ApplicationCommandOption.cs
  2. +3
    -0
      src/Discord.Net.Core/Entities/Interactions/SlashCommands/SlashCommandBuilder.cs

+ 4
- 0
src/Discord.Net.Core/Entities/Interactions/ApplicationCommandOption.cs View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace Discord
@@ -29,6 +30,9 @@ namespace Discord
if (!Regex.IsMatch(value, @"^[\w-]{1,32}$"))
throw new FormatException($"{nameof(value)} must match the regex ^[\\w-]{{1,32}}$");

if (value.Any(x => char.IsUpper(x)))
throw new FormatException("Name cannot contain any uppercase characters.");

_name = value;
}
}


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

@@ -40,6 +40,9 @@ namespace Discord
if (!Regex.IsMatch(value, @"^[\w-]{1,32}$"))
throw new ArgumentException("Command name cannot contain any special characters or whitespaces!", nameof(value));

if (value.Any(x => char.IsUpper(x)))
throw new FormatException("Name cannot contain any uppercase characters.");

_name = value;
}
}


Loading…
Cancel
Save