Has Permission function in discord v.13 (discord.js)

Viewed 2830

I tried to change my Clear Command so that it works on Discord v.13. My biggest Problem right now is the hasPermission function. I looked it up on the Discord.js/guide side and followed there instruction. Unfortunately I get this error when trying to change the old hasPermission function

My Intents:

const intents = new Discord.Intents(513);

const client = new Discord.Client({ intents });

My Clear Command right now:

client.on("messageCreate", async message => {

    if(message.author.bot) return;
    let parts = message.content.split(" ");

  
  if(parts[0] == '.c')
    if(!message.member.permissions.has(Permissions.FLAGS.MANAGE_ROLES)) return message.channel.send("You can't do that").then(m => m.delete({ timeout: 5000 }))
    if (!parts[1]) return message.channel.send('You forgot something here!').then(m => m.delete({ timeout: 3000 }))
    if (isNaN(parts[1])) return message.channel.send('Pls use a number!').then(m => m.delete({ timeout: 3000 }))
    if (parts[1] > 100) return message.channel.send('You can't delete more than 100 messages').then(m => m.delete({ timeout: 3000 }))
    if (parts[1] < 2) return message.channel.send('You can't delete less than 2 messages').then(m => m.delete({ timeout: 3000 }))
    message.channel.bulkDelete(parts[1])
    message.channel.send(`I deleted ${parts[1]} Messages!`).then(m => m.delete({ timeout: 3000 }))

My Error Code is:

if(!message.member.permissions.has(Permissions.FLAGS.MANAGE_ROLES)) return message.channel.send("You can't do that").then(m => m.delete({ timeout: 5000 })) 
                              ^

^ ReferenceError: Permissions is not defined

1 Answers

You have a typo there, it is

message.member.permissions.has();

You are missing s at the end of the permission

Related