Skip to content

Commit

Permalink
fix: unproper clean up on reconnection
Browse files Browse the repository at this point in the history
This commit fixes the issue that upon reconnection, it wouldn't clean up, causing bugs later on.
  • Loading branch information
ThePedroo committed Apr 13, 2024
1 parent aef0665 commit c7bd6aa
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,14 +290,13 @@ class Connection extends EventEmitter {
const closeCode = DISCORD_CLOSE_CODES[code]

if (closeCode?.reconnect) {
this._updatePlayerState({ status: 'idle', reason: 'reconnecting' })
this._destroyConnection(code, reason)

this.emit('reconnecting', reason)
this._updatePlayerState({ status: 'idle', reason: 'reconnecting' })

if (this.audioStream) {
this.pause()
this.connect(() => this.unpause('reconnected'), true)
}
this.connect(() => {
if (this.audioStream) this.unpause('reconnected')
}, true)
} else {
this._destroy({ status: 'disconnected', reason: 'websocketClose', code }, false)

Expand Down

0 comments on commit c7bd6aa

Please sign in to comment.