TypeError: MOD.hasPermissions is not a function

5.8k views Asked by At

I got the error: TypeError: MOD.hasPermissions is not a function!

Can you please help me?

const commando = require('discord.js-commando');

class KickCommand extends commando.Command {

  constructor(client) {
    super(client, {
      name: 'kick',
      group: 'mod',
      memberName: 'kick',
      description: 'Kicks a member'
    });
  }

  async run(message, args, args2) {

    const MOD = message.author;
    const user = message.mentions.members.first()
    const reason = args2;

    if (MOD.hasPermissions('KICK_MEMBERS', true)) {
      user.kick(reason);
    } else {
      message.reply('You don\'t have permission to kick members!');
    }
  }
}

module.exports = KickCommand;
1

There are 1 answers

2
swoods On BEST ANSWER

To find out if the person has a permission, you use message.member.hasPermision (Since guild member is used for Permissions in a server.) The message.member is the same as message.author, but you use this to get the permissions of the person who sent the message.

const MOD = message.member;
const user = message.mentions.members.first()
const reason = args2;

if (MOD.hasPermissions('KICK_MEMBERS')) {

    user.kick(reason);
})