Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix "TypeError: message.member.hasPermission is not a function" in Discord.js? [duplicate]

I was making Permissions Handler and I get the error "TypeError: message.member.hasPermission is not a function". What's my mistake?

        const validPermissions = [
        "CREATE_INSTANT_INVITE",
        "KICK_MEMBERS",
        "BAN_MEMBERS",
        "ADMINISTRATOR",
        "MANAGE_CHANNELS",
        "MANAGE_GUILD",
    ]

    if(command.permissions.length){
        let invalidPerms = []
        for(const perm of command.permissions){
          if(!validPermissions.includes(perm)){
            return console.log(`Invalid Permissions ${perm}`);
          }
          if(!message.member.hasPermission(perm)){
            invalidPerms.push(perm);
          }
        }
        if (invalidPerms.length){
          return message.channel.send(`Missing Permissions: \`${invalidPerms}\``);
        }
like image 540
XZen Avatar asked Oct 18 '25 10:10

XZen


1 Answers

message.member.hasPermission() has been removed in djs v13, you need to use message.member.permissions.has() now!

like image 124
MegaMix_Craft Avatar answered Oct 20 '25 00:10

MegaMix_Craft



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!