TypeError: Cannot read properties of undefined (reading 'hasPermission')


I am back again with again my ticket function. This time I am working on a close command. Whatever I try I always come back at the same errors:

TypeError: message.member.hasPermission is not a function

Anyone who can look at the code?

    const { MessageEmbed, Collection, Permissions } = require ('discord.js');

module.exports = {
    name: 'close',
    description: "closes the ticket",
    execute(message, args, client){
        if(!message.member.hasPermission("MANAGE_CHANNELS")) return message.channel.send("Only a moderator can end a ticket!")

        if(message.member.hasPermission("MANAGE_CHANNELS")) message.channel.delete()


this code will check if the member has the permission to MANAGE_CHANNELS and since .permissions.has() returns a boolean, it will either return true or false, if the user doesn’t have such permission it will return a message that they cannot use the command, else if it will delete the channel…

if(!message.member.permissions.has(Permissions.FLAGS.MANAGE_CHANNELS)) { 
  return message.channel.send("Only a moderator can end a ticket!")
} else {
  return message.channel.delete()

Answered By – gavin

Answer Checked By – Marie Seifert (AngularFixing Admin)

Leave a Reply

Your email address will not be published.