From 87bce990d9672427cfd707889a3aa1e4742337a2 Mon Sep 17 00:00:00 2001 From: Cenk Ergen <57065323+Cenngo@users.noreply.github.com> Date: Thu, 2 Dec 2021 21:17:28 +0300 Subject: [PATCH] Add uppercase character check to SlashCommandBuilder and ApplicationCommandOptionProperties (#339) --- .../Entities/Interactions/ApplicationCommandOption.cs | 4 ++++ .../Interactions/SlashCommands/SlashCommandBuilder.cs | 3 +++ 2 files changed, 7 insertions(+) diff --git a/src/Discord.Net.Core/Entities/Interactions/ApplicationCommandOption.cs b/src/Discord.Net.Core/Entities/Interactions/ApplicationCommandOption.cs index 9a69d9d18..5857bac81 100644 --- a/src/Discord.Net.Core/Entities/Interactions/ApplicationCommandOption.cs +++ b/src/Discord.Net.Core/Entities/Interactions/ApplicationCommandOption.cs @@ -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; } } diff --git a/src/Discord.Net.Core/Entities/Interactions/SlashCommands/SlashCommandBuilder.cs b/src/Discord.Net.Core/Entities/Interactions/SlashCommands/SlashCommandBuilder.cs index b4fc89cc2..074a52f32 100644 --- a/src/Discord.Net.Core/Entities/Interactions/SlashCommands/SlashCommandBuilder.cs +++ b/src/Discord.Net.Core/Entities/Interactions/SlashCommands/SlashCommandBuilder.cs @@ -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; } }