Add rating and scobble fields to track embed
This commit is contained in:
@@ -12,10 +12,34 @@ module.exports = {
|
|||||||
option.setName('links')
|
option.setName('links')
|
||||||
.setDescription('Links separated by space')
|
.setDescription('Links separated by space')
|
||||||
.setRequired(true))
|
.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 =>
|
.addStringOption(option =>
|
||||||
option.setName('title_override')
|
option.setName('title_override')
|
||||||
.setDescription('Custom title, otherwise uses title from Spotify')
|
.setDescription('Custom title, otherwise uses title from Spotify')
|
||||||
.setRequired(false))
|
.setRequired(false))
|
||||||
|
.addStringOption(option =>
|
||||||
|
option.setName('footer_override')
|
||||||
|
.setDescription('Custom footer')
|
||||||
|
.setRequired(false))
|
||||||
.addAttachmentOption(option =>
|
.addAttachmentOption(option =>
|
||||||
option.setName('cover_override')
|
option.setName('cover_override')
|
||||||
.setDescription('Uses this image instead of Spotofy metadata')
|
.setDescription('Uses this image instead of Spotofy metadata')
|
||||||
@@ -38,9 +62,8 @@ module.exports = {
|
|||||||
let spotifyID = null;
|
let spotifyID = null;
|
||||||
|
|
||||||
const trackEmbed = new EmbedBuilder()
|
const trackEmbed = new EmbedBuilder()
|
||||||
.setColor(0x0099FF)
|
.setColor(Math.floor(Math.random() * 16777214) + 1)
|
||||||
.setDescription(`asdasdasda`)
|
.setDescription(`asdasdasda`)
|
||||||
.setFooter({text:`Submitted by ${interaction.member.displayName}`})
|
|
||||||
.setTimestamp();
|
.setTimestamp();
|
||||||
|
|
||||||
for (let index = 0; index < urls.length; index++) {
|
for (let index = 0; index < urls.length; index++) {
|
||||||
@@ -72,7 +95,6 @@ module.exports = {
|
|||||||
|
|
||||||
if(spotifyID) {
|
if(spotifyID) {
|
||||||
let spotifyTrack = await this.spotifyAPI.getTrack(spotifyID);
|
let spotifyTrack = await this.spotifyAPI.getTrack(spotifyID);
|
||||||
console.log(spotifyTrack);
|
|
||||||
trackEmbed.setImage(spotifyTrack['body'].album.images[0].url);
|
trackEmbed.setImage(spotifyTrack['body'].album.images[0].url);
|
||||||
title = `${spotifyTrack['body'].name} - ${spotifyTrack['body'].artists.map(a => a.name).join(', ')}`;
|
title = `${spotifyTrack['body'].name} - ${spotifyTrack['body'].artists.map(a => a.name).join(', ')}`;
|
||||||
let releaseDate = new Date(spotifyTrack['body'].album.release_date).toDateString();
|
let releaseDate = new Date(spotifyTrack['body'].album.release_date).toDateString();
|
||||||
@@ -86,6 +108,22 @@ module.exports = {
|
|||||||
title = interaction.options.getString('title_override', false) ?? title;
|
title = interaction.options.getString('title_override', false) ?? title;
|
||||||
trackEmbed.setTitle(`${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) {
|
if(!description) {
|
||||||
await interaction.reply({content: 'Sorry, no valid link has bee supplied.', ephemeral: true });
|
await interaction.reply({content: 'Sorry, no valid link has bee supplied.', ephemeral: true });
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user