我试图做一个机器人,但是当我运行kick命令时

时间:2020-04-28 20:47:39

标签: javascript node.js discord.js

我运行了kick命令,并在下面收到此错误:

(node:13176) UnhandledPromiseRejectionWarning: TypeError: message.guild.channels.find is not a function
        at Object.run (C:\Users\somna\Desktop\bot\commands\moderation\kick.js:11:51)
        at Client.<anonymous> (C:\Users\somna\Desktop\bot\index.js:48:17)
        at Client.emit (events.js:310:20)
        at MessageCreateAction.handle (C:\Users\somna\Desktop\bot\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)    
        at Object.module.exports [as MESSAGE_CREATE] (C:\Users\somna\Desktop\bot\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
        at WebSocketManager.handlePacket (C:\Users\somna\Desktop\bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:386:31)
        at WebSocketShard.onPacket (C:\Users\somna\Desktop\bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:436:22)   
        at WebSocketShard.onMessage (C:\Users\somna\Desktop\bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:293:10)  
        at WebSocket.onMessage (C:\Users\somna\Desktop\bot\node_modules\ws\lib\event-target.js:120:16)
        at WebSocket.emit (events.js:310:20)

1 个答案:

答案 0 :(得分:2)

尽管您不包含任何代码,但由于错误,我可以断定您使用的是discord.js v12,而没有使用.cache

message.guild.channels.find()更改为message.guild.channels.cache.find()