"im sure its fine" ~hazel
This commit is contained in:
parent
a2cf556bcf
commit
2b92d56e28
1 changed files with 50 additions and 23 deletions
|
|
@ -29,9 +29,9 @@ function keepV(url: string): string {
|
|||
export default class PingCommand extends Command {
|
||||
async run(interaction: ChatInputCommandInteraction, config: Config) {
|
||||
await interaction.deferReply()
|
||||
|
||||
|
||||
const meow = await fetch(`https://api.listenbrainz.org/1/user/${config.listenbrainzAccount}/playing-now`).then((res) => res.json());
|
||||
const user = interaction.options.getString("user") ?? config.listenbrainzAccount;
|
||||
console.log(`https://api.listenbrainz.org/1/user/${user}/playing-now`);
|
||||
const meow = await fetch(`https://api.listenbrainz.org/1/user/${user}/playing-now`).then((res) => res.json());
|
||||
if (!meow) {
|
||||
await interaction.followUp("something shat itself!");
|
||||
return;
|
||||
|
|
@ -40,13 +40,11 @@ export default class PingCommand extends Command {
|
|||
await interaction.followUp("user isnt listening to music");
|
||||
} else {
|
||||
const track_metadata = meow.payload.listens[0].track_metadata
|
||||
if (track_metadata.additional_info.origin_url) {
|
||||
const link = keepV(track_metadata.additional_info.origin_url)
|
||||
|
||||
const preferredApi = getSongOnPreferredProvider(await fetch(`https://api.song.link/v1-alpha.1/links?url=${link}`).then(a => a.json()), link)
|
||||
if (!preferredApi) {
|
||||
await interaction.followUp("song not found")
|
||||
return
|
||||
}
|
||||
if (preferredApi) {
|
||||
const embed = new EmbedBuilder()
|
||||
.setAuthor({
|
||||
name: preferredApi.artist,
|
||||
|
|
@ -63,6 +61,33 @@ export default class PingCommand extends Command {
|
|||
],
|
||||
embeds: [embed]
|
||||
});
|
||||
return
|
||||
}
|
||||
|
||||
}
|
||||
let hasURL = false;
|
||||
if (track_metadata.additional_info.release_mbid) {
|
||||
const thing = await fetch(`https://coverartarchive.org/release/${track_metadata.additional_info.release_mbid}/front`, {
|
||||
method: "HEAD",
|
||||
redirect: "manual",
|
||||
})
|
||||
hasURL = thing.status === 307;
|
||||
}
|
||||
let embed = new EmbedBuilder()
|
||||
.setAuthor({
|
||||
name: track_metadata.artist_name,
|
||||
})
|
||||
.setTitle(track_metadata.track_name)
|
||||
.setDescription("could not get additional info")
|
||||
.setFooter({
|
||||
text: "amy jr",
|
||||
});
|
||||
if (hasURL) {
|
||||
embed.setThumbnail(`https://aart.yellows.ink/release/${track_metadata.additional_info.release_mbid}.webp`);
|
||||
}
|
||||
await interaction.followUp({
|
||||
embeds: [embed],
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -71,7 +96,9 @@ export default class PingCommand extends Command {
|
|||
.setName("nowplaying")
|
||||
.setDescription("balls").setIntegrationTypes([
|
||||
ApplicationIntegrationType.UserInstall
|
||||
])
|
||||
]).addStringOption(option => {
|
||||
return option.setName("user").setDescription("listenbrainz username").setRequired(false)
|
||||
})
|
||||
.setContexts([
|
||||
InteractionContextType.BotDM,
|
||||
InteractionContextType.Guild,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue