Skip to content

Commit

Permalink
fix(nowplaying): don't show progress if duration is missing from song
Browse files Browse the repository at this point in the history
  • Loading branch information
eritislami committed Nov 6, 2020
1 parent ee9af7b commit c385ef5
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions commands/nowplaying.js
Expand Up @@ -7,6 +7,7 @@ module.exports = {
execute(message) {
const queue = message.client.queue.get(message.guild.id);
if (!queue) return message.reply("There is nothing playing.").catch(console.error);

const song = queue.songs[0];
const seek = (queue.connection.dispatcher.streamTime - queue.connection.dispatcher.pausedTime) / 1000;
const left = song.duration - seek;
Expand All @@ -15,8 +16,10 @@ module.exports = {
.setTitle("Now playing")
.setDescription(`${song.title}\n${song.url}`)
.setColor("#F8AA2A")
.setAuthor("EvoBot")
.addField(
.setAuthor("EvoBot");

if (song.duration > 0) {
nowPlaying.addField(
"\u200b",
new Date(seek * 1000).toISOString().substr(11, 8) +
"[" +
Expand All @@ -25,9 +28,8 @@ module.exports = {
(song.duration == 0 ? " ◉ LIVE" : new Date(song.duration * 1000).toISOString().substr(11, 8)),
false
);

if (song.duration > 0)
nowPlaying.setFooter("Time Remaining: " + new Date(left * 1000).toISOString().substr(11, 8));
}

return message.channel.send(nowPlaying);
}
Expand Down

0 comments on commit c385ef5

Please sign in to comment.