Skip to content

crash: cannot read property 'cache' of undefined

Author: MRAAGH

After months of working flawlessly, my discord puppet bridge instance crashed with the following error:

Mar-18 05:06:48.061 [bot-sdk-Appservice] info: Processing ephemeral event of type m.receipt                                                                   
127.0.0.1 - - [18/Mar/2022:04:06:48 +0000] "PUT /transactions/12351261?access_token=<redacted> HTTP/1.1" 200 2 "-" "Synapse/1.51.0" 
/home/discordpuppet/mx-puppet-discord/node_modules/better-discord.js/src/client/actions/MessageCreate.js:11                                                   
      const existing = channel.messages.cache.get(data.id);
                                        ^

TypeError: Cannot read property 'cache' of undefined
    at MessageCreateAction.handle (/home/discordpuppet/mx-puppet-discord/node_modules/better-discord.js/src/client/actions/MessageCreate.js:11:41)            
    at Object.module.exports [as MESSAGE_CREATE] (/home/discordpuppet/mx-puppet-discord/node_modules/better-discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
    at WebSocketManager.handlePacket (/home/discordpuppet/mx-puppet-discord/node_modules/better-discord.js/src/client/websocket/WebSocketManager.js:391:31)   
    at WebSocketShard.onPacket (/home/discordpuppet/mx-puppet-discord/node_modules/better-discord.js/src/client/websocket/WebSocketShard.js:451:22)           
    at WebSocketShard.onMessage (/home/discordpuppet/mx-puppet-discord/node_modules/better-discord.js/src/client/websocket/WebSocketShard.js:308:10)          
    at WebSocket.onMessage (/home/discordpuppet/mx-puppet-discord/node_modules/ws/lib/event-target.js:132:16)                                                 
    at WebSocket.emit (events.js:400:28)
    at Receiver.receiverOnMessage (/home/discordpuppet/mx-puppet-discord/node_modules/ws/lib/websocket.js:970:20)                                             
    at Receiver.emit (events.js:400:28)
    at Receiver.dataMessage (/home/discordpuppet/mx-puppet-discord/node_modules/ws/lib/receiver.js:517:14)                                                    
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! mx-puppet-discord@0.0.0 start: `npm run-script build && node ./build/index.js`                                                                       
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the mx-puppet-discord@0.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.                                                            

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/discordpuppet/.npm/_logs/2022-03-18T04_06_48_717Z-debug.log