Regex error when setting name of subcommand integer option

Hey. I'm trying to set the name of a subcommand option, yet I get this weird regex error from doing so that I haven't quite figured out yet. Any thoughts? See comments for error. Related code snippet:
const data = new SlashCommandBuilder()
.setName("lobby")
.setDescription("Lets you make or join a lobby!")
.addSubcommand(subcommand =>
subcommand
.setName("new")
.setDescription("Creats a new lobby!")
)
.addSubcommand(subcommand =>
subcommand
.setName("join")
.setDescription("Lets you join a lobby!")
.addIntegerOption(option =>
option
.setName("ID") // This is where the error gets thrown out.
.setDescription("ID of the lobby you wish to join.")
.setMinValue(1)
.setRequired(true)
)
)
const data = new SlashCommandBuilder()
.setName("lobby")
.setDescription("Lets you make or join a lobby!")
.addSubcommand(subcommand =>
subcommand
.setName("new")
.setDescription("Creats a new lobby!")
)
.addSubcommand(subcommand =>
subcommand
.setName("join")
.setDescription("Lets you join a lobby!")
.addIntegerOption(option =>
option
.setName("ID") // This is where the error gets thrown out.
.setDescription("ID of the lobby you wish to join.")
.setMinValue(1)
.setRequired(true)
)
)
2 Replies
d.js toolkit
d.js toolkit3d ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
Fractal Pixel
Fractal PixelOP3d ago
Error message:
C:\Users\User\Documents\Discord Bots\Bot\Files\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:2475
return regex.test(input) ? Result.ok(input) : Result.err(new ExpectedConstraintError(type, options?.message ?? "Invalid string format", input, expected));
^

ExpectedConstraintError: Invalid string format
at Object.run (C:\Users\User\Documents\Discord Bots\Bot\Files\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:2475:64)
at C:\Users\User\Documents\Discord Bots\Bot\Files\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:972:67
at Array.reduce (<anonymous>)
at _StringValidator.parse (C:\Users\User\Documents\Discord Bots\Bot\Files\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:972:29)
at validateName (C:\Users\User\Documents\Discord Bots\Bot\Files\node_modules\@discordjs\builders\dist\index.js:1599:17)
at MixedClass.setName (C:\Users\User\Documents\Discord Bots\Bot\Files\node_modules\@discordjs\builders\dist\index.js:1701:5)
at C:\Users\User\Documents\Discord Bots\Bot\Files\dist\commands\Game\lobby.js:25:6
at MixedClass._sharedAddOptionMethod (C:\Users\User\Documents\Discord Bots\Bot\Files\node_modules\@discordjs\builders\dist\index.js:2439:50)
at MixedClass.addStringOption (C:\Users\User\Documents\Discord Bots\Bot\Files\node_modules\@discordjs\builders\dist\index.js:2411:17)
at C:\Users\User\Documents\Discord Bots\Bot\Files\dist\commands\Game\lobby.js:24:6 {
constraint: 's.string().regex()',
given: 'ID',
expected: 'expected /^[\\p{Ll}\\p{Lm}\\p{Lo}\\p{N}\\p{sc=Devanagari}\\p{sc=Thai}_-]+$/u.test(expected) to be true'
}
C:\Users\User\Documents\Discord Bots\Bot\Files\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:2475
return regex.test(input) ? Result.ok(input) : Result.err(new ExpectedConstraintError(type, options?.message ?? "Invalid string format", input, expected));
^

ExpectedConstraintError: Invalid string format
at Object.run (C:\Users\User\Documents\Discord Bots\Bot\Files\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:2475:64)
at C:\Users\User\Documents\Discord Bots\Bot\Files\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:972:67
at Array.reduce (<anonymous>)
at _StringValidator.parse (C:\Users\User\Documents\Discord Bots\Bot\Files\node_modules\@sapphire\shapeshift\dist\cjs\index.cjs:972:29)
at validateName (C:\Users\User\Documents\Discord Bots\Bot\Files\node_modules\@discordjs\builders\dist\index.js:1599:17)
at MixedClass.setName (C:\Users\User\Documents\Discord Bots\Bot\Files\node_modules\@discordjs\builders\dist\index.js:1701:5)
at C:\Users\User\Documents\Discord Bots\Bot\Files\dist\commands\Game\lobby.js:25:6
at MixedClass._sharedAddOptionMethod (C:\Users\User\Documents\Discord Bots\Bot\Files\node_modules\@discordjs\builders\dist\index.js:2439:50)
at MixedClass.addStringOption (C:\Users\User\Documents\Discord Bots\Bot\Files\node_modules\@discordjs\builders\dist\index.js:2411:17)
at C:\Users\User\Documents\Discord Bots\Bot\Files\dist\commands\Game\lobby.js:24:6 {
constraint: 's.string().regex()',
given: 'ID',
expected: 'expected /^[\\p{Ll}\\p{Lm}\\p{Lo}\\p{N}\\p{sc=Devanagari}\\p{sc=Thai}_-]+$/u.test(expected) to be true'
}
Running node v v22.14.0 and discord.js v 14.18.0 i am an idiot Thank you @Qjuh, that is in fact the problem. I've been stuck on this for over 20 minutes.

Did you find this page helpful?