@@ -207,10 +207,9 @@ public SlashCommandBuilder AddOption(string name, ApplicationCommandOptionType t
207207 {
208208 Preconditions . Options ( name , description ) ;
209209
210- // Discord updated the docs, this regex prevents special characters like @!$%( and s p a c e s.. etc,
211- // https://discord.com/developers/docs/interactions/slash-commands#applicationcommand
212- if ( ! Regex . IsMatch ( name , @"^[\w-]{1,32}$" ) )
213- throw new ArgumentException ( "Command name cannot contain any special characters or whitespaces!" , nameof ( name ) ) ;
210+ // https://discord.com/developers/docs/interactions/application-commands
211+ if ( ! Regex . IsMatch ( name , @"^[-_\p{L}\p{N}\p{IsDevanagari}\p{IsThai}]{1,32}$" ) )
212+ throw new ArgumentException ( @"Name must match the regex ^[-_\p{L}\p{N}\p{IsDevanagari}\p{IsThai}]{1,32}$" , nameof ( name ) ) ;
214213
215214 // make sure theres only one option with default set to true
216215 if ( isDefault == true && Options ? . Any ( x => x . IsDefault == true ) == true )
@@ -376,12 +375,11 @@ internal static void EnsureValidCommandName(string name)
376375 Preconditions . AtLeast ( name . Length , 1 , nameof ( name ) ) ;
377376 Preconditions . AtMost ( name . Length , MaxNameLength , nameof ( name ) ) ;
378377
379- // Discord updated the docs, this regex prevents special characters like @!$%(... etc,
380- // https://discord.com/developers/docs/interactions/slash-commands#applicationcommand
381- if ( ! Regex . IsMatch ( name , @"^[\w-]{1,32}$" ) )
382- throw new ArgumentException ( "Command name cannot contain any special characters or whitespaces!" , nameof ( name ) ) ;
378+ // https://discord.com/developers/docs/interactions/application-commands
379+ if ( ! Regex . IsMatch ( name , @"^[-_\p{L}\p{N}\p{IsDevanagari}\p{IsThai}]{1,32}$" ) )
380+ throw new ArgumentException ( @"Name must match the regex ^[-_\p{L}\p{N}\p{IsDevanagari}\p{IsThai}]{1,32}$" , nameof ( name ) ) ;
383381
384- if ( name . Any ( x => char . IsUpper ( x ) ) )
382+ if ( name . Any ( char . IsUpper ) )
385383 throw new FormatException ( "Name cannot contain any uppercase characters." ) ;
386384 }
387385
@@ -587,10 +585,9 @@ public SlashCommandOptionBuilder AddOption(string name, ApplicationCommandOption
587585 {
588586 Preconditions . Options ( name , description ) ;
589587
590- // Discord updated the docs, this regex prevents special characters like @!$%( and s p a c e s.. etc,
591- // https://discord.com/developers/docs/interactions/slash-commands#applicationcommand
592- if ( ! Regex . IsMatch ( name , @"^[\w-]{1,32}$" ) )
593- throw new ArgumentException ( "Command name cannot contain any special characters or whitespaces!" , nameof ( name ) ) ;
588+ // https://discord.com/developers/docs/interactions/application-commands
589+ if ( ! Regex . IsMatch ( name , @"^[-_\p{L}\p{N}\p{IsDevanagari}\p{IsThai}]{1,32}$" ) )
590+ throw new ArgumentException ( @"Name must match the regex ^[-_\p{L}\p{N}\p{IsDevanagari}\p{IsThai}]{1,32}$" , nameof ( name ) ) ;
594591
595592 // make sure theres only one option with default set to true
596593 if ( isDefault && Options ? . Any ( x => x . IsDefault == true ) == true )
@@ -966,8 +963,10 @@ private static void EnsureValidCommandOptionName(string name)
966963 {
967964 Preconditions . AtLeast ( name . Length , 1 , nameof ( name ) ) ;
968965 Preconditions . AtMost ( name . Length , SlashCommandBuilder . MaxNameLength , nameof ( name ) ) ;
969- if ( ! Regex . IsMatch ( name , @"^[\w-]{1,32}$" ) )
970- throw new ArgumentException ( "Option name cannot contain any special characters or whitespaces!" , nameof ( name ) ) ;
966+
967+ // https://discord.com/developers/docs/interactions/application-commands
968+ if ( ! Regex . IsMatch ( name , @"^[-_\p{L}\p{N}\p{IsDevanagari}\p{IsThai}]{1,32}$" ) )
969+ throw new ArgumentException ( @"Name must match the regex ^[-_\p{L}\p{N}\p{IsDevanagari}\p{IsThai}]{1,32}$" , nameof ( name ) ) ;
971970 }
972971
973972 private static void EnsureValidCommandOptionDescription ( string description )
0 commit comments