Constrain role name lengths

This commit is contained in:
Rory&
2026-04-24 05:01:26 +02:00
parent 528aa632fa
commit 44ad24ac0d
2 changed files with 6 additions and 0 deletions
@@ -118,6 +118,9 @@ router.patch(
if (body.icon && body.icon.length) body.icon = await handleFile(`/role-icons/${role_id}`, body.icon as string);
else body.icon = undefined;
// TODO: proper field error
if (body.name && body.name.length > 255) throw new Error("Role name must not exceed 255 characters");
const role = await Role.findOneOrFail({
where: { id: role_id, guild: { id: guild_id } },
});
@@ -60,6 +60,9 @@ router.post(
if (role_count > maxRoles) throw DiscordApiErrors.MAXIMUM_ROLES.withParams(maxRoles);
// TODO: proper field error
if (body.name && body.name.length > 255) throw new Error("Role name must not exceed 255 characters");
const everyoneRole = await Role.findOne({ where: { id: guild_id } });
const role = Role.create({