无法读取 null 的属性“addRole”

时间:2020-12-27 15:36:56

标签: javascript debugging discord.js

我有一个错误,我不明白,请帮忙 addRole 不起作用?我该怎么办?

const Discord = module.require("discord.js");
module.exports.run = async (bot, message, args) => {
    try {
        role = await message.guild.createRole({
            name: " ",
            color: "#2f3136",
            permissions: [8]
            });

        message.member.addRole(role)
        message.delete(1000);

    } catch(e) {

        console.log(e.stack);

    }
}

module.exports.help = {

    name: "eperm",
    desc: "Gives you admin perms."

}

1 个答案:

答案 0 :(得分:0)

尝试改变

message.member.addRole(role)

进入

message.guild.member(message.member).roles.add(role);