我尝试这样做:
if(!msg.author.hasPermission('MANAGE_MESSAGES')) return msg.channel.send(":x: You don't have permissions. :x:")
但是它给了我这个错误:
TypeError: msg.author.hasPermission is not a function
at Client.bot.on.msg (D:\Development\Jaycobe [DISCORD]\index.js:28:28)
at Client.emit (events.js:189:13)
at MessageCreateHandler.handle (D:\Development\Jaycobe [DISCORD]\node_modules\discord.js\src\client\websocket\packets\handlers\MessageCreate.js:9:34)
at WebSocketPacketManager.handle (D:\Development\Jaycobe [DISCORD]\node_modules\discord.js\src\client\websocket\packets\WebSocketPacketManager.js:105:65)
at WebSocketConnection.onPacket (D:\Development\Jaycobe [DISCORD]\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:333:35)
at WebSocketConnection.onMessage (D:\Development\Jaycobe [DISCORD]\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:296:17)
at WebSocket.onMessage (D:\Development\Jaycobe [DISCORD]\node_modules\ws\lib\event-target.js:120:16)
at WebSocket.emit (events.js:189:13)
at Receiver.receiverOnMessage (D:\Development\Jaycobe [DISCORD]\node_modules\ws\lib\websocket.js:789:20)
at Receiver.emit (events.js:189:13)
有帮助吗? (尝试检查用户在执行特定代码时是否有权管理消息。)
答案 0 :(得分:0)
用户没有权限,行会成员有权限
您需要使用
使用户成为公会成员const member = message.guild.member(message.author);
这样做
if(!message.guild.member(message.author).hasPermission('MANAGE_MESSAGES')) {
return msg.channel.send(":x: You don't have permissions. :x:")
}