cmd.user.edit.roles.remove
Removes one or more roles from a guild member. Roles are removed one at a time in the order provided.
JavaScript
const { cmd } = require("syntx.js");
await cmd.user.edit.roles.remove({ user, roles }, message);Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
user | string | Yes | The ID of the member to remove roles from. |
roles | string[] | Yes | Array of role IDs to remove. Must contain at least one entry. |
message | discord.js Message | Yes | A guild message or interaction, used to access the guild. |
Returns
This function does not return a value.
Example
JavaScript
client.command({
name: "removerole",
content: async (message) => {
const id = cmd.message.mentioned(message, 1);
if (!id) return message.reply("Please mention a user.");
await cmd.user.edit.roles.remove(
{
user: id,
roles: ["ROLE_ID_1", "ROLE_ID_2"],
},
message
);
message.reply("Roles removed.");
},
});Warning
The bot must have the Manage Roles permission and its highest role must be above each role it is trying to remove. If any role ID is not found in the guild, a SyntxError is thrown immediately and remaining roles in the array will not be processed.