我正在尝试执行softmute
命令,但出现此错误:TypeError: Cannot read property 'add' of undefined
const muteduser = message.mentions.users.first();
const muterole = message.guild.roles.cache.find(r => r.name == 'Muted')
if (message.guild.member(muteduser).bannable) {
const ismember = message.guild.member(muteduser)
muteduser.roles.add(muterole.id);
答案 0 :(得分:0)
您遇到的问题是由于您将muteduser
定义为User
而不是GuildMember
。
您需要将const muteduser = message.mentions.users.first();
替换为const muteduser = message.mentions.members.first();