问题
Making a kick command.
I am trying to make a command so that the admins cannot kick each other.
if(message.author.hasPermission('KICK_MEMBER', 'ADMINISTRATOR') && message.member.hasPermission('KICK_MEMBER', 'ADMINISTRATOR'))
return ('You cant kick another admin!')
But I get an error.
TypeError: message.author.hasPermission is not a function
回答1:
So basically you are trying to use message.author.hasPermission('permission'). The property author of the message object is a User, which is a Discord user. You need to reference the GuildMember, using message.member.hasPermission('permission').
Also, it looks like you are trying to compare the same person (message.author and message.member are the same person, only one is a User and the other is a GuildMember). You need to compare message.member.hasPermission() with otherMember.hasPermission().
来源:https://stackoverflow.com/questions/62342075/make-admins-not-kick-each-other