muthera 1.0.13 → 1.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "muthera",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "description": "A simple Lavalink wrapper for Discord music bot. Forked from Niizuki.",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -27,7 +27,9 @@ class Connection {
27
27
  this.region = endpoint.split(".").shift()?.replace(/[0-9]/g, "") || null;
28
28
 
29
29
  setTimeout(() => {
30
- this.player.pause(false)
30
+ if (this.player.current) {
31
+ this.player.pause(false);
32
+ }
31
33
  }, 5000);
32
34
 
33
35
  this.updatePlayerVoiceData();
@@ -188,7 +188,7 @@ class Player extends EventEmitter {
188
188
 
189
189
  let track =
190
190
  response.tracks[
191
- Math.floor(Math.random() * Math.floor(response.tracks.length))
191
+ Math.floor(Math.random() * Math.floor(response.tracks.length))
192
192
  ];
193
193
 
194
194
  if (this.connected) {
@@ -623,13 +623,25 @@ class Player extends EventEmitter {
623
623
  }
624
624
 
625
625
  socketClosed(player, payload) {
626
- if ([4015, 4009].includes(payload.code)) {
626
+ // If the socket was closed abruptly by Discord (Voice Server Crash, Disconnected, Normal Closure)
627
+ if ([4015, 4009, 4014, 1000].includes(payload.code)) {
628
+ // Send a ping to forcefully reset the ghost Discord.js Cache if it is stuck
627
629
  this.send({
628
630
  guild_id: payload.guildId,
629
- channel_id: this.voiceChannel,
630
- self_mute: this.mute,
631
- self_deaf: this.deaf,
631
+ channel_id: null,
632
+ self_mute: false,
633
+ self_deaf: false,
632
634
  });
635
+
636
+ // After 500ms, seamlessly reconnect the bot back to the correct voice channel
637
+ setTimeout(() => {
638
+ this.send({
639
+ guild_id: payload.guildId,
640
+ channel_id: this.voiceChannel,
641
+ self_mute: this.mute,
642
+ self_deaf: this.deaf,
643
+ });
644
+ }, 500);
633
645
  }
634
646
 
635
647
  this.muthera.emit("socketClosed", player, payload);