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.96k stars 2.88k forks source link

Seek command can cause a crash if 24/7 is enabled while bot is not playing anything. #718

Closed xayanide closed 2 years ago

xayanide commented 2 years ago

Please describe the problem you are having in as much detail as possible: Seek command can cause a crash if 24/7 is enabled while bot is not playing anything.

Prerequisites

Reproduction Steps

  1. Play any track with the music bot on a channel.
  2. End the track e.g., >skip or >seek to the end of the track.
  3. While the bot is not playing anything, use seek command, e.g., >seek 1s

    In this step, the bot should still be in the channel while it is not playing anything because 24/7 is enabled.

  4. Bot crashes.

    See error on console

    
    C:\Users\A\Desktop\Test\Discord-MusicBot-master\commands\seek.js:40
    if (!player.queue.current.isSeekable)
    ^

TypeError: Cannot read properties of null (reading 'isSeekable') at Object.run (C:\Users\A\Desktop\Test\Discord-MusicBot-master\commands\se ek.js:40:31) at processTicksAndRejections (node:internal/process/task_queues:96:5)

Node.js v17.4.0


**Expected Behaviour**
Bot is supposed to say this string
` ❌ | **Nothing is playing right now...**"`

**Possible Fix**
https://github.com/SudhanPlayz/Discord-MusicBot/blob/1a73e72dce3a4b282f8cb5a8ec3c66e43b612840/commands/seek.js#L26
```diff
-      );
+      );
+   if (!player.queue.current)
+      return client.sendTime(
+        message.channel,
+        "❌ | **Nothing is playing right now...**"
+      );

Bot no longer crashes after I added this on my end, the fix could be better, I guess.

Include a reproducible code sample here, if possible: N/A

Further details:

Relevant client options:

DarrenOfficial commented 2 years ago

Fixed in v5.