chalda / DiscordBot

A chat bot for discord app based off discord.js
GNU General Public License v2.0
583 stars 355 forks source link

Crash #204

Open Einarin opened 3 years ago

Einarin commented 3 years ago

Bot crashed, saving the console output to debug later.

ErrorEvent {
  target: WebSocket {
    _events: [Object: null prototype] {
      open: [Function],
      message: [Function],
      close: [Function],
      error: [Function]
    },
    _eventsCount: 4,
    _maxListeners: undefined,
    _binaryType: 'nodebuffer',
    _closeCode: 1006,
    _closeFrameReceived: false,
    _closeFrameSent: false,
    _closeMessage: '',
    _closeTimer: null,
    _extensions: {},
    _protocol: '',
    _readyState: 2,
    _receiver: null,
    _sender: null,
    _socket: null,
    _bufferedAmount: 0,
    _isServer: false,
    _redirects: 0,
    _url: 'wss://us-south8214.discord.media/?v=4&encoding=json',
    _req: ClientRequest {
      _events: [Object: null prototype],
      _eventsCount: 4,
      _maxListeners: undefined,
      outputData: [],
      outputSize: 0,
      writable: true,
      _last: true,
      chunkedEncoding: false,
      shouldKeepAlive: true,
      useChunkedEncodingByDefault: false,
      sendDate: false,
      _removedConnection: false,
      _removedContLen: false,
      _removedTE: false,
      _contentLength: 0,
      _hasBody: true,
      _trailer: '',
      finished: true,
      _headerSent: true,
      socket: [TLSSocket],
      connection: [TLSSocket],
      _header: 'GET /?v=4&encoding=json HTTP/1.1\r\n' +
        'Sec-WebSocket-Version: 13\r\n' +
        'Sec-WebSocket-Key: LaesumTeLqya6UeGU1ofLA==\r\n' +
        'Connection: Upgrade\r\n' +
        'Upgrade: websocket\r\n' +
        'Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits\r\n' +
        'Host: us-south8214.discord.media\r\n' +
        '\r\n',
      _onPendingData: [Function: noopPendingOutput],
      agent: undefined,
      socketPath: undefined,
      method: 'GET',
      insecureHTTPParser: undefined,
      path: '/?v=4&encoding=json',
      _ended: false,
      res: null,
      aborted: true,
      timeoutCb: null,
      upgradeOrConnect: false,
      parser: [HTTPParser],
      maxHeadersCount: null,
      [Symbol(kNeedDrain)]: false,
      [Symbol(isCorked)]: false,
      [Symbol(kOutHeaders)]: [Object: null prototype]
    }
  },
  type: 'error',
  message: 'WebSocket was closed before the connection was established',
  error: Error: WebSocket was closed before the connection was established
      at WebSocket.close (D:\Projects\DiscordBotWindows\node_modules\ws\lib\websocket.js:224:14)
      at VoiceWebSocket.reset (D:\Projects\DiscordBotWindows\node_modules\discord.js\src\client\voice\networking\VoiceWebSocket.js:53:60)
      at VoiceWebSocket.shutdown (D:\Projects\DiscordBotWindows\node_modules\discord.js\src\client\voice\networking\VoiceWebSocket.js:44:10)
      at VoiceConnection.emit (events.js:228:7)
      at VoiceConnection.disconnect (D:\Projects\DiscordBotWindows\node_modules\discord.js\src\client\voice\VoiceConnection.js:352:10)
      at Player.stop_playing (D:\Projects\DiscordBotWindows\plugins\MusicPlayer\player.js:225:20)
      at StreamDispatcher.<anonymous> (D:\Projects\DiscordBotWindows\plugins\MusicPlayer\player.js:199:26)
      at StreamDispatcher.emit (events.js:223:5)
      at StreamDispatcher._setSpeaking (D:\Projects\DiscordBotWindows\node_modules\discord.js\src\client\voice\dispatcher\StreamDispatcher.js:310:10)
      at D:\Projects\DiscordBotWindows\node_modules\discord.js\src\client\voice\dispatcher\StreamDispatcher.js:296:12
}
Download started
filename: PINK GUY - STFU-OLpeX4RRo28.mp4
size: 20056922
YoutubeDL Stream end
YoutubeDL stream close
D:\Projects\DiscordBotWindows\plugins\MusicPlayer\player.js:166
            if(this.queue[0].response){
                             ^

TypeError: Cannot read property 'response' of undefined
    at Timeout._onTimeout (D:\Projects\DiscordBotWindows\plugins\MusicPlayer\player.js:166:30)
    at listOnTimeout (internal/timers.js:531:17)
    at processTimers (internal/timers.js:475:7)
F9Alejandro commented 2 years ago

Maybe a try catch around that if statement or set what the if is validating as a variable in the try catch to then get the bot to disconnect from the VC and empty the queue?