From 86a1596bfc8a1742450971fd2eb2b69f32cf5726 Mon Sep 17 00:00:00 2001 From: Minz Date: Wed, 3 Apr 2024 14:24:45 +0200 Subject: [PATCH] Add rating and scobble fields to track embed --- commands/utility/linkTrack.js | 44 ++++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/commands/utility/linkTrack.js b/commands/utility/linkTrack.js index 56001f6..bb00ff0 100644 --- a/commands/utility/linkTrack.js +++ b/commands/utility/linkTrack.js @@ -12,10 +12,34 @@ module.exports = { option.setName('links') .setDescription('Links separated by space') .setRequired(true)) + .addStringOption(option => + option.setName('rating') + .setDescription('Optionally provide your rating') + .setRequired(false) + .addChoices( + { name: '1', value: '<:1:1221744574897197097>' }, + { name: '2', value: '<:2:1221744576751075398>' }, + { name: '3', value: '<:3:1221744578273607680>' }, + { name: '4', value: '<:4:1221744638574989385>' }, + { name: '5', value: '<:5:1221744581670993970>' }, + { name: '6', value: '<:6:1221744566890266667>' }, + { name: '7', value: '<:7:1221744568202956800>' }, + { name: '8', value: '<:8:1221744569406717954>' }, + { name: '9', value: '<:9_:1221744570531053620>' }, + { name: '10', value: '<:10:1221744572326215680>' }, + )) + .addIntegerOption(option => + option.setName('scrobbles') + .setDescription('Your scrobble count at the time of submission') + .setRequired(false)) .addStringOption(option => option.setName('title_override') .setDescription('Custom title, otherwise uses title from Spotify') .setRequired(false)) + .addStringOption(option => + option.setName('footer_override') + .setDescription('Custom footer') + .setRequired(false)) .addAttachmentOption(option => option.setName('cover_override') .setDescription('Uses this image instead of Spotofy metadata') @@ -38,9 +62,8 @@ module.exports = { let spotifyID = null; const trackEmbed = new EmbedBuilder() - .setColor(0x0099FF) + .setColor(Math.floor(Math.random() * 16777214) + 1) .setDescription(`asdasdasda`) - .setFooter({text:`Submitted by ${interaction.member.displayName}`}) .setTimestamp(); for (let index = 0; index < urls.length; index++) { @@ -72,7 +95,6 @@ module.exports = { if(spotifyID) { let spotifyTrack = await this.spotifyAPI.getTrack(spotifyID); - console.log(spotifyTrack); trackEmbed.setImage(spotifyTrack['body'].album.images[0].url); title = `${spotifyTrack['body'].name} - ${spotifyTrack['body'].artists.map(a => a.name).join(', ')}`; let releaseDate = new Date(spotifyTrack['body'].album.release_date).toDateString(); @@ -86,6 +108,22 @@ module.exports = { title = interaction.options.getString('title_override', false) ?? title; trackEmbed.setTitle(`${title}`); + let submitterName = interaction.member.displayName; + let footer = interaction.options.getString('footer_override', false) ?? `Submitted by ${submitterName}`; + trackEmbed.setFooter({text: footer }); + + if(interaction.options.getString('rating', false)) { + trackEmbed.addFields( + { name: `${submitterName} rated this`, value: `${interaction.options.getString('rating', false)} out of 10`, inline: true }, + ) + } + + if(interaction.options.getInteger('scrobbles', false)) { + trackEmbed.addFields( + { name: `${submitterName} scrobbled this`, value: `${interaction.options.getInteger('scrobbles', false)} times so far`, inline: true }, + ) + } + if(!description) { await interaction.reply({content: 'Sorry, no valid link has bee supplied.', ephemeral: true }); return;