From b25ce254b27e9e97c1624769ab3b9ac2a7489c9f Mon Sep 17 00:00:00 2001 From: AnxietyisReal <96593068+AnxietyisReal@users.noreply.github.com> Date: Sat, 2 Sep 2023 09:25:48 +1000 Subject: [PATCH] Add Spotify status to whois --- src/commands/whois.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/commands/whois.ts b/src/commands/whois.ts index 4adfc65..c691bbc 100644 --- a/src/commands/whois.ts +++ b/src/commands/whois.ts @@ -44,9 +44,22 @@ export default { {name: `🔹 Roles: ${member.roles.cache.size - 1}`, value: member.roles.cache.size > 1 ? member.roles.cache.filter(x=>x.id !== interaction.guild.roles.everyone.id).sort((a,b)=>b.position - a.position).map(x=>x).join(member.roles.cache.size > 4 ? ' ' : '\n').slice(0,1024) : 'No roles'} ) if (member.premiumSinceTimestamp !== null) embed.addFields({name: '🔹 Server Boosting since', value: `\n`, inline: true}) - if (!presence) embed.addFields({name: `🔹 Status: Unavailable to be fetched`, value: '\u200b'}) + if (!presence) embed.addFields({name: `🔹 Status: ⚫`, value: '\u200b'}) if (member.presence) embed.addFields({name: `🔹 Status: ${member.presence.status}`, value: `${member.presence.status === 'offline' ? '⚫' : `Desktop: ${convert(presence.desktop)}\nWeb: ${convert(presence.web)}\nMobile: ${convert(presence.mobile)}`}`, inline: true}) embedArray.push(embed) + if (member.presence.activities.find(a=>a.type === 2)/* && member.presence.activities.find(a=>a.type === 2)?.assets */) { + const spotifyStatus = member.presence?.activities.find(a=>a.name === 'Spotify') as Discord.Activity; + const spotifyEmbed = new client.embed() + .setColor('#1DB954') // Thanks Copilot, I never knew I needed this shade of green. It's actually looks like Spotify's color. + .setThumbnail(spotifyStatus?.assets.largeImageURL()) + .setAuthor({name: 'Spotify', iconURL: 'https://cdn.discordapp.com/emojis/510214342034325504.webp?quality=lossless'}) + .addFields( + {name: 'Artist', value: spotifyStatus?.state, inline: true}, + {name: 'Album', value: spotifyStatus?.details, inline: true}, + {name: 'Started', value: `\n`, inline: false} + ) + embedArray.push(spotifyEmbed) + } interaction.reply({embeds: embedArray}) } },