fix: trim command name and description fields

This commit is contained in:
CyberL1 2025-10-20 09:28:46 +02:00 committed by Rory&
parent df80d2070c
commit ec8727dc6f
4 changed files with 24 additions and 24 deletions

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,