SudhanPlayz / Discord-MusicBot

An advanced discord music bot, supports Spotify, Soundcloud, YouTube with Shuffling, Volume Control and Web Dashboard with Slash Commands support!
https://musicbot.darrenofficial.com
Other
2.93k stars 2.85k forks source link

If users type in voice channel chat v4 bot will crash, hotfix below #1247

Closed nullpat closed 11 months ago

nullpat commented 1 year ago

Actual solution will be to use v5 when its feature equivalent to v4, might be worth leaving this issue visible until then, if you get below error

Jul 20 20:25:22 ip-.ec2.internal node[1130810]: /home/ec2-user/Discord-MusicBot/node_modules/discord.js/src/client/actions/MessageCreate.js:11
Jul 20 20:25:22 ip-.ec2.internal node[1130810]:       const existing = channel.messages.cache.get(data.id);
Jul 20 20:25:22 ip-.ec2.internal node[1130810]:                                         ^
Jul 20 20:25:22 ip-.ec2.internal node[1130810]: TypeError: Cannot read properties of undefined (reading 'cache')
Jul 20 20:25:22 ip-.ec2.internal node[1130810]:     at MessageCreateAction.handle (/home/ec2-user/Discord-MusicBot/node_modules/discord.js/src/client/actions/MessageCreate.js:11:41)
Jul 20 20:25:22 ip-.ec2.internal node[1130810]:     at Object.module.exports [as MESSAGE_CREATE] (/home/ec2-user/Discord-MusicBot/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
Jul 20 20:25:22 ip-.ec2.internal node[1130810]:     at WebSocketManager.handlePacket (/home/ec2-user/Discord-MusicBot/node_modules/discord.js/src/client/websocket/WebSocketManager.js:384:31)
Jul 20 20:25:22 ip-.ec2.internal node[1130810]:     at WebSocketShard.onPacket (/home/ec2-user/Discord-MusicBot/node_modules/discord.js/src/client/websocket/WebSocketShard.js:444:22)
Jul 20 20:25:22 ip-.ec2.internal node[1130810]:     at WebSocketShard.onMessage (/home/ec2-user/Discord-MusicBot/node_modules/discord.js/src/client/websocket/WebSocketShard.js:301:10)
Jul 20 20:25:22 ip-.ec2.internal node[1130810]:     at WebSocket.onMessage (/home/ec2-user/Discord-MusicBot/node_modules/discord.js/node_modules/ws/lib/event-target.js:132:16)
Jul 20 20:25:22 ip-.ec2.internal node[1130810]:     at WebSocket.emit (node:events:513:28)
Jul 20 20:25:22 ip-.ec2.internal node[1130810]:     at Receiver.receiverOnMessage (/home/ec2-user/Discord-MusicBot/node_modules/discord.js/node_modules/ws/lib/websocket.js:1068:20)
Jul 20 20:25:22 ip-.ec2.internal node[1130810]:     at Receiver.emit (node:events:513:28)
Jul 20 20:25:22 ip-.ec2.internal node[1130810]:     at Receiver.dataMessage (/home/ec2-user/Discord-MusicBot/node_modules/discord.js/node_modules/ws/lib/receiver.js:517:14)
Jul 20 20:25:22 ip-.ec2.internal systemd[1]: musicbot.service: Main process exited, code=exited, status=1/FAILURE

you can hotfix your own local fork of node_modules/discord.js/src/client/actions/MessageCreate.js and replace line 10 from if (channel) to if (channel && channel.messages)

as well as node_modules/discord.js/src/client/actions/Action.js adding

    if (!manager) {
      return null;
    }

to getPayload(data, manager, id, partialType, cache) {

phanhiep579x commented 11 months ago

it doesn't work for me..

DarrenOfficial commented 11 months ago

v4 is considered deprecated at this point, use the v5 branch.