Discord Bot TypeError:无法读取未定义的属性“id”

时间:2021-05-14 13:52:25

标签: javascript node.js discord

所以我目前正在编辑一个过去的包不和谐机器人来跟踪网站上的更新,大约 8 个月前我第一次编辑代码时它已经工作了(这是一个刮掉的代码),但是我已尝试运行 node index.js,但错误显示如下。

    at ClientDataManager.newChannel (C:\Users\benet\Downloads\weebHook-master\node_modules\discord.js\src\client\ClientDataManager.js:81:36)
    at Guild.setup (C:\Users\benet\Downloads\weebHook-master\node_modules\discord.js\src\structures\Guild.js:307:68)
    at GuildCreateHandler.handle (C:\Users\benet\Downloads\weebHook-master\node_modules\discord.js\src\client\websocket\packets\handlers\GuildCreate.js:12:15)
    at WebSocketPacketManager.handle (C:\Users\benet\Downloads\weebHook-master\node_modules\discord.js\src\client\websocket\packets\WebSocketPacketManager.js:108:65)
    at WebSocketConnection.onPacket (C:\Users\benet\Downloads\weebHook-master\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:336:35)
    at WebSocketConnection.onMessage (C:\Users\benet\Downloads\weebHook-master\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:299:17)
    at WebSocket.onMessage (C:\Users\benet\Downloads\weebHook-master\node_modules\discord.js\node_modules\ws\lib\event-target.js:120:16)
    at WebSocket.emit (events.js:376:20)
    at Receiver.receiverOnMessage (C:\Users\benet\Downloads\weebHook-master\node_modules\discord.js\node_modules\ws\lib\websocket.js:789:20)
    at Receiver.emit (events.js:376:20)
    at Receiver.dataMessage (C:\Users\benet\Downloads\weebHook-master\node_modules\discord.js\node_modules\ws\lib\receiver.js:413:14)
    at Receiver.getData (C:\Users\benet\Downloads\weebHook-master\node_modules\discord.js\node_modules\ws\lib\receiver.js:352:17)
    at Receiver.startLoop (C:\Users\benet\Downloads\weebHook-master\node_modules\discord.js\node_modules\ws\lib\receiver.js:138:22)
    at Receiver._write (C:\Users\benet\Downloads\weebHook-master\node_modules\discord.js\node_modules\ws\lib\receiver.js:74:10)
    at writeOrBuffer (internal/streams/writable.js:358:12)
    at Receiver.Writable.write (internal/streams/writable.js:303:10)
    at TLSSocket.socketOnData (C:\Users\benet\Downloads\weebHook-master\node_modules\discord.js\node_modules\ws\lib\websocket.js:864:35)
    at TLSSocket.emit (events.js:376:20)
    at addChunk (internal/streams/readable.js:309:12)
    at readableAddChunk (internal/streams/readable.js:284:9)
    at TLSSocket.Readable.push (internal/streams/readable.js:223:10)
    at TLSWrap.onStreamRead (internal/stream_base_commons.js:188:23)```

I have no idea how to fix this problem...
Here is my package.json :

    {
  "name": "weebhook",
  "version": "1.0.0",
  "description": "webhook for discord that checks for updates on specified mangas on mangakakalot",
  "main": "index.js",
  "bin": "bin.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/Elynejs/weebhook.git"
  },
  "author": "Elyne",
  "license": "MIT",
  "bugs": {
    "url": "https://github.com/Elynejs/weebhook/issues"
  },
  "homepage": "https://github.com/Elynejs/weebhook#readme",
  "devDependencies": {
    "eslint": "^6.2.2"
  },
  "dependencies": {
    "cheerio": "^1.0.0-rc.9",
    "discord.js": "^11.6.4",
    "request": "^2.88.0",
    "request-promise": "^4.2.4",
    "ws": "^7.4.5"
  }
}

1 个答案:

答案 0 :(得分:-1)

也许 discord.js 版本已经过时并且现在不兼容了?我看到需要 node.js 版本 12。

"discord.js": "^11.6.4"

https://discord.js.org/#/docs/main/stable/general/welcome