cmd.role.create
Creates a new role in the guild. Supports solid, gradient, and holographic color styles, as well as icons, permissions, and position.
const { cmd } = require("syntx.js");
await cmd.role.create({ name, color, colors, colorStyle, hoist, mentionable, permissions, icon, unicodeEmoji, position, reason }, message);Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | Yes | The name of the role. |
color | string | number | No | Shorthand for setting the primary color. Ignored if colors.primary is also set. |
colors | object | No | Fine-grained color control. See color styles below. |
colorStyle | string | No | Color rendering style: "solid", "gradient", or "holographic". Defaults to "solid". |
hoist | boolean | No | Whether to display members with this role separately in the member list. Defaults to false. |
mentionable | boolean | No | Whether anyone can mention this role. Defaults to false. |
permissions | string[] | No | Array of permission flag strings to grant. Defaults to []. |
icon | string | No | URL or file path for the role icon. Requires the guild to have at least Level 2 boost. |
unicodeEmoji | string | No | Unicode emoji to use as the role icon. Requires at least Level 2 boost. |
position | number | No | Position of the role in the hierarchy. |
reason | string | No | Audit log reason for the action. |
message | discord.js Message | Yes | A guild message or interaction, used to access the guild. |
Color styles
"solid" (default)
A single flat color. Use color or colors.primary to set it:
{ color: "#ff5733" }
// or
{ colors: { primary: "#ff5733" }, colorStyle: "solid" }Passing colors.secondary alongside "solid" throws a SyntxError.
"gradient"
A two-color gradient. Both colors.primary and colors.secondary are required:
{
colorStyle: "gradient",
colors: { primary: "#ff5733", secondary: "#3399ff" }
}"holographic"
Discord's built-in holographic rainbow effect. No custom colors can be provided; the palette is applied automatically by Discord:
{ colorStyle: "holographic" }Passing any color or colors value alongside "holographic" throws a SyntxError.
Returns
An object describing the created role, with the same shape as the return value of cmd.role.info, except without the assignedMembers field.
| Field | Type | Description |
|---|---|---|
id | string | The new role's ID. |
name | string | The role's name. |
color | string | The primary color as a hex string. |
colorStyle | string | The resolved color style: "solid", "gradient", or "holographic". |
colors | object | The full color set: { primary, secondary, tertiary }. |
icon | string | null | URL of the role icon, or null. |
unicodeEmoji | string | null | The role's unicode emoji, or null. |
position | number | The role's position in the hierarchy. |
permissions | string[] | Array of granted permission flag strings. |
hoist | boolean | Whether the role is hoisted. |
mentionable | boolean | Whether the role is mentionable. |
managed | boolean | Whether the role is managed by an integration. |
editable | boolean | Whether the bot can edit this role. |
flags | string[] | Array of role flag strings. |
tags | object | null | Role tags, if any. |
createdAt | Date | When the role was created. |
Examples
Create a basic role
client.command({
name: "createrole",
content: async (message) => {
const role = await cmd.role.create(
{
name: "Members",
color: "#3399ff",
hoist: true,
mentionable: true,
},
message
);
message.reply(`Role created: <@&${role.id}>`);
},
});Create a gradient role
client.command({
name: "gradientrole",
content: async (message) => {
const role = await cmd.role.create(
{
name: "Nitro Fan",
colorStyle: "gradient",
colors: {
primary: "#ff73fa",
secondary: "#7289da",
},
hoist: true,
},
message
);
message.reply(`Gradient role created: <@&${role.id}>`);
},
});Create a holographic role
client.command({
name: "hologrole",
content: async (message) => {
const role = await cmd.role.create(
{
name: "✨ Special",
colorStyle: "holographic",
mentionable: false,
reason: "Special event role",
},
message
);
message.reply(`Holographic role created: <@&${role.id}>`);
},
});Warning
The bot must have the Manage Roles permission and its own highest role must be above the position where the new role will be placed. Role icons and unicode emojis require the guild to have at least Level 2 boost. If any of these conditions are not met, a SyntxError is thrown.