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,