MuteUser = message.mentions.members.first();
MuteRole = message.guild.roles.cache.get("x")
我想像使用“ .rolemute @Muted”一样更改角色
答案 0 :(得分:0)
您可以简单地定义静音角色:
var mutedRole = message.guild.roles.cache.get("x")
然后,如果您想通过消息进行更改:
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.
答案 1 :(得分:0)
message.mentions
返回MessageMentions
类的实例。除了具有members
和users
属性之外,它还具有channels
,幸运的是,roles
!
const MuteRole = message.mentions.roles.first();