fix: Fixed retrieving play count for some tracks that does not have track.views set

This commit is contained in:
Marius Begby committed 2023-07-15 04:41:24 +02:00
1 parent 2e1a73386a
commit ea4df17195
1 file changed
+14 -3
+14 -3
View File
@@ -64,8 +64,17 @@ module.exports = {
if (author === 'cdn.discordapp.com') { if (author === 'cdn.discordapp.com') {
author = 'Unavailable'; author = 'Unavailable';
} }
const plays = let plays = currentTrack.views !== 0 ? currentTrack.views : 0;
currentTrack.views !== 0 ? currentTrack.views : 'Unavailable'; if (plays === 0) {
if (
currentTrack.metadata.bridge.views !== 0 &&
currentTrack.metadata.bridge.views !== undefined
) {
plays = currentTrack.metadata.bridge.views;
} else {
plays = 'Unavailable';
}
}
const source = const source =
sourceStringsFormatted.get(currentTrack.raw.source) ?? sourceStringsFormatted.get(currentTrack.raw.source) ??
'Unavailable'; 'Unavailable';
@@ -195,7 +204,9 @@ module.exports = {
embeds: [ embeds: [
new EmbedBuilder() new EmbedBuilder()
.setAuthor({ .setAuthor({
name: interaction.member.nickname || interaction.user.username, name:
interaction.member.nickname ||
interaction.user.username,
iconURL: interaction.user.avatarURL() iconURL: interaction.user.avatarURL()
}) })
.setDescription( .setDescription(