takeRole
Removes a role from a specified user.
Syntax
takeRole(userID, roleID)
Parameters
userID
: The user of whose role is to get removed. Value must be a valid user snowflake ID.roleID
: The role to take from the user. Value must be a valid role snowflake ID.
Permissions
Required permission which the bot must have for this function to work properly:
manageroles
Example
try {
const msg = message.replace(commandPrefix, '').trim().replace(/ +/g, ' ').split(' ', 2);
if (!msg[0]) {
setResponse(`Usage : \` ${commandPrefix} [@user] [@role] \``);
} else {
const
userMention = /^<@!?(\d{17,20})>$/.test(msg[0]),
roleMention = /^<@&!?(\d{17,20})>$/.test(msg[1]);
if (!userMention || !userMentions[0])
throw new Error('Mention an user!');
if (!roleMention || !roleMentions[0])
throw new Error('Mention a role!');
sendChannelMessage(channelId, `Removed <@&${roleMentions[0]}> from <@${userMentions[0]}>!`);
takeRole(userMentions[0], roleMentions[0]);
};
} catch (err) {
setResponse('Command Error : ` ' + err.message + ' `');
};