fix: trim more

This commit is contained in:
CyberL1 2025-10-22 18:02:23 +02:00
parent 97eef84e8c
commit f24ec09f2a
4 changed files with 12 additions and 9 deletions

View File

@ -95,7 +95,7 @@ router.patch(
version: Snowflake.generate(),
};
await ApplicationCommand.update({ name: body.name }, commandForDb);
await ApplicationCommand.update({ name: body.name.trim() }, commandForDb);
res.send(commandForDb);
},
);

View File

@ -83,10 +83,10 @@ router.post(
version: Snowflake.generate(),
};
const commandExists = await ApplicationCommand.exists({ where: { application_id: req.params.application_id, name: body.name } });
const commandExists = await ApplicationCommand.exists({ where: { application_id: req.params.application_id, name: body.name.trim() } });
if (commandExists) {
await ApplicationCommand.update({ application_id: req.params.application_id, name: body.name }, commandForDb);
await ApplicationCommand.update({ application_id: req.params.application_id, name: body.name.trim() }, commandForDb);
} else {
commandForDb.id = Snowflake.generate(); // Have to be done that way so the id doesn't change
await ApplicationCommand.save(commandForDb);
@ -154,10 +154,10 @@ router.put(
version: Snowflake.generate(),
};
const commandExists = await ApplicationCommand.exists({ where: { application_id: req.params.application_id, name: command.name } });
const commandExists = await ApplicationCommand.exists({ where: { application_id: req.params.application_id, name: command.name.trim() } });
if (commandExists) {
await ApplicationCommand.update({ application_id: req.params.application_id, name: command.name }, commandForDb);
await ApplicationCommand.update({ application_id: req.params.application_id, name: command.name.trim() }, commandForDb);
} else {
commandForDb.id = Snowflake.generate(); // Have to be done that way so the id doesn't change
await ApplicationCommand.save(commandForDb);

View File

@ -113,7 +113,7 @@ router.patch(
};
const commandExists = await ApplicationCommand.exists({
where: { application_id: req.params.application_id, guild_id: req.params.guild_id, id: req.params.command_id, name: body.name },
where: { application_id: req.params.application_id, guild_id: req.params.guild_id, id: req.params.command_id, name: body.name.trim() },
});
if (!commandExists) {
@ -121,7 +121,10 @@ router.patch(
return;
}
await ApplicationCommand.update({ application_id: req.params.application_id, guild_id: req.params.guild_id, id: req.params.command_id, name: body.name }, commandForDb);
await ApplicationCommand.update(
{ application_id: req.params.application_id, guild_id: req.params.guild_id, id: req.params.command_id, name: body.name.trim() },
commandForDb,
);
res.send(commandForDb);
},
);

View File

@ -107,10 +107,10 @@ router.post(
version: Snowflake.generate(),
};
const commandExists = await ApplicationCommand.exists({ where: { application_id: req.params.application_id, guild_id: req.params.guild_id, name: body.name } });
const commandExists = await ApplicationCommand.exists({ where: { application_id: req.params.application_id, guild_id: req.params.guild_id, name: body.name.trim() } });
if (commandExists) {
await ApplicationCommand.update({ application_id: req.params.application_id, guild_id: req.params.guild_id, name: body.name }, commandForDb);
await ApplicationCommand.update({ application_id: req.params.application_id, guild_id: req.params.guild_id, name: body.name.trim() }, commandForDb);
} else {
commandForDb.id = Snowflake.generate(); // Have to be done that way so the id doesn't change
await ApplicationCommand.save(commandForDb);