From ea4df17195f2dc810843b3bd73f3e1c9e8653524 Mon Sep 17 00:00:00 2001 From: Marius Begby Date: Sat, 15 Jul 2023 04:41:24 +0200 Subject: [PATCH] fix: Fixed retrieving play count for some tracks that does not have track.views set --- commands/nowplaying.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/commands/nowplaying.js b/commands/nowplaying.js index 9214694..a259751 100644 --- a/commands/nowplaying.js +++ b/commands/nowplaying.js @@ -64,8 +64,17 @@ module.exports = { if (author === 'cdn.discordapp.com') { author = 'Unavailable'; } - const plays = - currentTrack.views !== 0 ? currentTrack.views : 'Unavailable'; + let plays = currentTrack.views !== 0 ? currentTrack.views : 0; + if (plays === 0) { + if ( + currentTrack.metadata.bridge.views !== 0 && + currentTrack.metadata.bridge.views !== undefined + ) { + plays = currentTrack.metadata.bridge.views; + } else { + plays = 'Unavailable'; + } + } const source = sourceStringsFormatted.get(currentTrack.raw.source) ?? 'Unavailable'; @@ -195,7 +204,9 @@ module.exports = { embeds: [ new EmbedBuilder() .setAuthor({ - name: interaction.member.nickname || interaction.user.username, + name: + interaction.member.nickname || + interaction.user.username, iconURL: interaction.user.avatarURL() }) .setDescription(