我正在为我的机器人执行角色分配命令,因此用户可以键入h.addrole @user @role
,如果该用户具有该角色,我将尝试输入该字符,每次我尝试输入时,都会输出This user already has this role!
使用命令,它总是输出
(node:5224) UnhandledPromiseRejectionWarning: TypeError: userToModify.hasRole is not a function
我的代码如下:
} if (message.content.startsWith(config.prefix + "addrole")) {
let userToModify = message.mentions.members.first();
let roleToAdd = message.mentions.roles.first();
if (userToModify.hasRole(roleToAdd)) return message.channel.send("This user already has this role!")
if (!args) return message.channel.send("Please enter a mentioned user and a mentioned role to assign (e.g h.addrole @Brickman @Moderator")
if (!message.member.hasPermission("MANAGE_ROLES")) return message.channel.send("You do not have permission for this!")
userToModify.addRole(roleToAdd);
return message.channel.send("Succesfully added role " + roleToAdd + " to member " + userToModify + "!");
答案 0 :(得分:1)
就像说... $sql = "SELECT * FROM oath WHERE name LIKE '%".$query."%' AND phone LIKE '%".$mob."%'";
不是函数。
相反,请尝试如下操作:
hasRole