mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-04 01:40:08 +00:00
role name must be less than 100 characters (#2584)
This commit is contained in:
@@ -42,7 +42,7 @@ export async function createRole(
|
||||
}
|
||||
|
||||
export interface CreateGuildRole {
|
||||
/** Name of the role, default: "new role" */
|
||||
/** Name of the role, max 100 characters, default: "new role" */
|
||||
name?: string;
|
||||
/** Bitwise value of the enabled/disabled permissions, default: everyone permissions in guild */
|
||||
permissions?: PermissionStrings[];
|
||||
|
||||
@@ -39,7 +39,7 @@ export async function editRole(bot: Bot, guildId: BigString, roleId: BigString,
|
||||
}
|
||||
|
||||
export interface EditGuildRole {
|
||||
/** Name of the role, default: "new role" */
|
||||
/** Name of the role, max 100 characters, default: "new role" */
|
||||
name?: string;
|
||||
/** Bitwise value of the enabled/disabled permissions, default: everyone permissions in guild */
|
||||
permissions?: PermissionStrings[];
|
||||
|
||||
@@ -7,6 +7,10 @@ export function createRole(bot: BotWithCache) {
|
||||
bot.helpers.createRole = async function (guildId, options, reason) {
|
||||
requireBotGuildPermissions(bot, bot.transformers.snowflake(guildId), ["MANAGE_ROLES"]);
|
||||
|
||||
if (options.name && !bot.utils.validateLength(options.name, { max: 100 })) {
|
||||
throw new Error("Role name must be less than 100 characters");
|
||||
}
|
||||
|
||||
return await createRole(guildId, options, reason);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { BotWithCache } from "../../deps.ts";
|
||||
import { higherRolePosition } from "../permissions.ts";
|
||||
import { highestRole, requireBotGuildPermissions } from "../permissions.ts";
|
||||
import { higherRolePosition, highestRole, requireBotGuildPermissions } from "../permissions.ts";
|
||||
|
||||
export function editRole(bot: BotWithCache) {
|
||||
const editRole = bot.helpers.editRole;
|
||||
@@ -26,6 +25,10 @@ export function editRole(bot: BotWithCache) {
|
||||
requireBotGuildPermissions(bot, guild, ["MANAGE_ROLES"]);
|
||||
}
|
||||
|
||||
if (options.name && !bot.utils.validateLength(options.name, { max: 100 })) {
|
||||
throw new Error("Role name must be less than 100 characters");
|
||||
}
|
||||
|
||||
return await editRole(guildId, id, options);
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user