option to disable song.link proxying
This commit is contained in:
parent
1fd32b8a20
commit
6088de8682
2 changed files with 19 additions and 5 deletions
|
|
@ -30,7 +30,8 @@ export default class PingCommand extends Command {
|
||||||
async run(interaction: ChatInputCommandInteraction, config: Config) {
|
async run(interaction: ChatInputCommandInteraction, config: Config) {
|
||||||
await interaction.deferReply()
|
await interaction.deferReply()
|
||||||
const user = interaction.options.getString("user") ?? config.listenbrainzAccount;
|
const user = interaction.options.getString("user") ?? config.listenbrainzAccount;
|
||||||
console.log(`https://api.listenbrainz.org/1/user/${user}/playing-now`);
|
const usesonglink = interaction.options.getBoolean("usesonglink") ?? true
|
||||||
|
|
||||||
const meow = await fetch(`https://api.listenbrainz.org/1/user/${user}/playing-now`).then((res) => res.json());
|
const meow = await fetch(`https://api.listenbrainz.org/1/user/${user}/playing-now`).then((res) => res.json());
|
||||||
if (!meow) {
|
if (!meow) {
|
||||||
await interaction.followUp("something shat itself!");
|
await interaction.followUp("something shat itself!");
|
||||||
|
|
@ -46,7 +47,8 @@ export default class PingCommand extends Command {
|
||||||
const link = itunesinfo.trackViewUrl
|
const link = itunesinfo.trackViewUrl
|
||||||
const songlink = await fetch(`https://api.song.link/v1-alpha.1/links?url=${link}`).then(a => a.json())
|
const songlink = await fetch(`https://api.song.link/v1-alpha.1/links?url=${link}`).then(a => a.json())
|
||||||
const preferredApi = getSongOnPreferredProvider(songlink, link)
|
const preferredApi = getSongOnPreferredProvider(songlink, link)
|
||||||
if (preferredApi) {
|
|
||||||
|
if (preferredApi && usesonglink) {
|
||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setAuthor({
|
.setAuthor({
|
||||||
name: preferredApi.artist,
|
name: preferredApi.artist,
|
||||||
|
|
@ -83,7 +85,16 @@ export default class PingCommand extends Command {
|
||||||
embeds: [embed]
|
embeds: [embed]
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
await interaction.followUp("what")
|
const embedfallback = new EmbedBuilder()
|
||||||
|
.setAuthor({
|
||||||
|
name: meow.payload.listens[0].track_metadata.artist_name
|
||||||
|
})
|
||||||
|
.setTitle(meow.payload.listens[0].track_metadata.track_name)
|
||||||
|
.setFooter({
|
||||||
|
text: "song.link proxying was turned off or failed - amy jr",
|
||||||
|
});
|
||||||
|
|
||||||
|
await interaction.followUp({embeds:[embedfallback]})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -93,7 +104,11 @@ export default class PingCommand extends Command {
|
||||||
.setName("nowplaying")
|
.setName("nowplaying")
|
||||||
.setDescription("balls").setIntegrationTypes([
|
.setDescription("balls").setIntegrationTypes([
|
||||||
ApplicationIntegrationType.UserInstall
|
ApplicationIntegrationType.UserInstall
|
||||||
]).addStringOption(option => {
|
])
|
||||||
|
.addBooleanOption(option => {
|
||||||
|
return option.setName("usesonglink").setDescription("use songlink or not").setRequired(false)
|
||||||
|
})
|
||||||
|
.addStringOption(option => {
|
||||||
return option.setName("user").setDescription("listenbrainz username").setRequired(false)
|
return option.setName("user").setDescription("listenbrainz username").setRequired(false)
|
||||||
})
|
})
|
||||||
.setContexts([
|
.setContexts([
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@ export default class MusicInfoCommand extends Command {
|
||||||
|
|
||||||
//const meow = [...new Set(Object.values(info.linksByPlatform).map((i:any) => i.entityUniqueId))]
|
//const meow = [...new Set(Object.values(info.linksByPlatform).map((i:any) => i.entityUniqueId))]
|
||||||
const meow = Object.keys(info.linksByPlatform)
|
const meow = Object.keys(info.linksByPlatform)
|
||||||
let message = ""
|
|
||||||
|
|
||||||
const nya: ActionRowBuilder<ButtonBuilder>[] = [];
|
const nya: ActionRowBuilder<ButtonBuilder>[] = [];
|
||||||
let currentRow = new ActionRowBuilder<ButtonBuilder>();
|
let currentRow = new ActionRowBuilder<ButtonBuilder>();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue