Discord权限检查不起作用dsicord js



由于某种原因,当我尝试使用命令时,它总是给我这个错误。下面列出了错误和代码。我试着把它修好了

const Discord = require("discord.js");
module.exports = {
name: 'clear',
aliases: ['purge'],
discription: "clears messages",
async execute(message, args, client) {
if (!message.member.hasPermission('MANAGE_MESSAGES')) return message.reply('You do not have permissions to use this command')
if (!args[0]) return message.reply(`Please specify a amount of messages to delete (1-99)`)
if (isNaN(args[0])) return message.reply(`Please enter a number`)
if (parseInt(args[0]) > 99) return message.reply(` The max amount of messages you may delete is 99`)
await message.channel.bulkDelete(parseInt(args[0]) + 1)
.catch(err => console.log(err))
message.channel.send(`deleted ${args[0]} messages`).then(m => m.delete({ timeout: 5000 }))
}
}
PS C:UserslolzyOneDriveDesktopdiscordbot> node .
Cbs slave is online!
(node:10108) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'hasPermission' of undefined

试试这个:

const Discord = require("discord.js");
module.exports = {
name: 'clear',
aliases: ['purge'],
discription: "clears messages",
async execute(client, message, args) {
if (!message.member.hasPermission("MANAGE_MESSAGES")) return message.channel,send('You do not have permissions to use this command')
if (!args[0]) return message.reply(`Please specify a amount of messages to delete (1-99)`)
if (isNaN(args[0])) return message.reply(`Please enter a number`)
if (parseInt(args[0]) > 99) return message.reply(` The max amount of messages you may delete is 99`)
await message.channel.bulkDelete(parseInt(args[0]) + 1)
.catch(err => console.log(err))
message.channel.send(`deleted ${args[0]} messages`).then(m => m.delete({ timeout: 5000 }))
}
}

最新更新