summary refs log tree commit diff
path: root/src/api
diff options
context:
space:
mode:
authorCyberL1 <cyber.hf18@gmail.com>2025-10-20 09:28:46 +0200
committerRory& <root@rory.gay>2025-10-20 10:07:36 +0200
commitec8727dc6f00dc26346b9d633e8955c470bd61fc (patch)
tree7abf1684c5b35b1d0f3bd5e29c221b163e0a5936 /src/api
parentfix: don't emit ephemeral interaction replies to channel, but only to user in... (diff)
downloadserver-ts-ec8727dc6f00dc26346b9d633e8955c470bd61fc.tar.xz
fix: trim command `name` and `description` fields
Diffstat (limited to 'src/api')
-rw-r--r--src/api/routes/applications/#application_id/commands/#command_id/index.ts8
-rw-r--r--src/api/routes/applications/#application_id/commands/index.ts16
-rw-r--r--src/api/routes/applications/#application_id/guilds/#guild_id/commands/#command_id/index.ts8
-rw-r--r--src/api/routes/applications/#application_id/guilds/#guild_id/commands/index.ts16
4 files changed, 24 insertions, 24 deletions
diff --git a/src/api/routes/applications/#application_id/commands/#command_id/index.ts b/src/api/routes/applications/#application_id/commands/#command_id/index.ts

index 80700ed6..b478fdd5 100644 --- a/src/api/routes/applications/#application_id/commands/#command_id/index.ts +++ b/src/api/routes/applications/#application_id/commands/#command_id/index.ts
@@ -67,10 +67,10 @@ router.patch( body.type = 1; } - if (body.name.length < 1 || body.name.length > 32) { + if (body.name.trim().length < 1 || body.name.trim().length > 32) { // TODO: configurable? throw FieldErrors({ - username: { + name: { code: "BASE_TYPE_BAD_LENGTH", message: `Must be between 1 and 32 in length.`, }, @@ -79,9 +79,9 @@ router.patch( const commandForDb: ApplicationCommandSchema = { application_id: req.params.application_id, - name: body.name, + name: body.name.trim(), name_localizations: body.name_localizations, - description: body.description || "", + description: body.description?.trim() || "", description_localizations: body.description_localizations, default_member_permissions: body.default_member_permissions || null, contexts: body.contexts, diff --git a/src/api/routes/applications/#application_id/commands/index.ts b/src/api/routes/applications/#application_id/commands/index.ts
index 50113cee..a855b15e 100644 --- a/src/api/routes/applications/#application_id/commands/index.ts +++ b/src/api/routes/applications/#application_id/commands/index.ts
@@ -54,10 +54,10 @@ router.post( body.type = 1; } - if (body.name.length < 1 || body.name.length > 32) { + if (body.name.trim().length < 1 || body.name.trim().length > 32) { // TODO: configurable? throw FieldErrors({ - username: { + name: { code: "BASE_TYPE_BAD_LENGTH", message: `Must be between 1 and 32 in length.`, }, @@ -66,9 +66,9 @@ router.post( const commandForDb: ApplicationCommandSchema = { application_id: req.params.application_id, - name: body.name, + name: body.name.trim(), name_localizations: body.name_localizations, - description: body.description || "", + description: body.description?.trim() || "", description_localizations: body.description_localizations, default_member_permissions: body.default_member_permissions || null, contexts: body.contexts, @@ -115,10 +115,10 @@ router.put( command.type = 1; } - if (command.name.length < 1 || command.name.length > 32) { + if (command.name.trim().length < 1 || command.name.trim().length > 32) { // TODO: configurable? throw FieldErrors({ - username: { + name: { code: "BASE_TYPE_BAD_LENGTH", message: `Must be between 1 and 32 in length.`, }, @@ -127,9 +127,9 @@ router.put( const commandForDb: ApplicationCommandSchema = { application_id: req.params.application_id, - name: command.name, + name: command.name.trim(), name_localizations: command.name_localizations, - description: command.description || "", + description: command.description?.trim() || "", description_localizations: command.description_localizations, default_member_permissions: command.default_member_permissions || null, contexts: command.contexts, diff --git a/src/api/routes/applications/#application_id/guilds/#guild_id/commands/#command_id/index.ts b/src/api/routes/applications/#application_id/guilds/#guild_id/commands/#command_id/index.ts
index c00835a3..94a2171c 100644 --- a/src/api/routes/applications/#application_id/guilds/#guild_id/commands/#command_id/index.ts +++ b/src/api/routes/applications/#application_id/guilds/#guild_id/commands/#command_id/index.ts
@@ -84,10 +84,10 @@ router.patch( body.type = 1; } - if (body.name.length < 1 || body.name.length > 32) { + if (body.name.trim().length < 1 || body.name.trim().length > 32) { // TODO: configurable? throw FieldErrors({ - username: { + name: { code: "BASE_TYPE_BAD_LENGTH", message: `Must be between 1 and 32 in length.`, }, @@ -96,9 +96,9 @@ router.patch( const commandForDb: ApplicationCommandSchema = { application_id: req.params.application_id, - name: body.name, + name: body.name.trim(), name_localizations: body.name_localizations, - description: body.description || "", + description: body.description?.trim() || "", description_localizations: body.description_localizations, default_member_permissions: body.default_member_permissions || null, contexts: body.contexts, diff --git a/src/api/routes/applications/#application_id/guilds/#guild_id/commands/index.ts b/src/api/routes/applications/#application_id/guilds/#guild_id/commands/index.ts
index 38ec8b0e..8e6fb787 100644 --- a/src/api/routes/applications/#application_id/guilds/#guild_id/commands/index.ts +++ b/src/api/routes/applications/#application_id/guilds/#guild_id/commands/index.ts
@@ -78,10 +78,10 @@ router.post( body.type = 1; } - if (body.name.length < 1 || body.name.length > 32) { + if (body.name.trim().length < 1 || body.name.trim().length > 32) { // TODO: configurable? throw FieldErrors({ - username: { + name: { code: "BASE_TYPE_BAD_LENGTH", message: `Must be between 1 and 32 in length.`, }, @@ -91,9 +91,9 @@ router.post( const commandForDb: ApplicationCommandSchema = { application_id: req.params.application_id, guild_id: req.params.guild_id, - name: body.name, + name: body.name.trim(), name_localizations: body.name_localizations, - description: body.description || "", + description: body.description?.trim() || "", description_localizations: body.description_localizations, default_member_permissions: body.default_member_permissions || null, contexts: body.contexts, @@ -152,10 +152,10 @@ router.put( command.type = 1; } - if (command.name.length < 1 || command.name.length > 32) { + if (command.name.trim().length < 1 || command.name.trim().length > 32) { // TODO: configurable? throw FieldErrors({ - username: { + name: { code: "BASE_TYPE_BAD_LENGTH", message: `Must be between 1 and 32 in length.`, }, @@ -165,9 +165,9 @@ router.put( const commandForDb: ApplicationCommandSchema = { application_id: req.params.application_id, guild_id: req.params.guild_id, - name: command.name, + name: command.name.trim(), name_localizations: command.name_localizations, - description: command.description || "", + description: command.description?.trim() || "", description_localizations: command.description_localizations, default_member_permissions: command.default_member_permissions || null, contexts: command.contexts,