I want to set roles by Chat | Discord.js v12 [closed]

You can simply define the muted role:

var mutedRole = message.guild.roles.cache.get("x")

Then if you ever want to change by a message:

var prefix = '.';
if (message.content.toLowerCase().startsWith(prefix + 'rolemute') { //when the command "rolemute" is said...
    let args = message.content.slice(prefix.length).trim().split(/ +/g); //split the message.
    if (!args[1]) return message.channel.send('You have not mentioned a new muted role.'); //if user did not mention a new role return a message.
    mutedRole = message.mentions.roles.first() || message.guild.roles.cache.get(args[1]); //define the new role.
    if (!mutedRole) return message.channel.send('I could not find the role you have specified.'); //If the role does not exist in the guild.
    message.channel.send(`Your muted role is now set to ${mutedRole}.`); //If the new muted role was successful.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top