mirror of
https://gitlab.com/bignutty/labscore.git
synced 2025-06-09 14:43:05 -04:00
fix yt thumbnail issue, sync ctx and regular audio command
This commit is contained in:
parent
4e39b12073
commit
26562317ca
2 changed files with 20 additions and 9 deletions
|
@ -29,23 +29,30 @@ module.exports = {
|
||||||
let urls = message.content.match(urlr)
|
let urls = message.content.match(urlr)
|
||||||
if(urls){
|
if(urls){
|
||||||
try{
|
try{
|
||||||
let songlink = await superagent.get(`https://api.song.link/v1-alpha.1/links?url=${encodeURIComponent(urls[0])}`)
|
let songlink = await superagent.get(`https://api.song.link/v1-alpha.1/links`)
|
||||||
|
.query({
|
||||||
|
url: urls[0],
|
||||||
|
key: process.env.SONGLINK_KEY
|
||||||
|
})
|
||||||
let song = songlink.body.entitiesByUniqueId[songlink.body.entityUniqueId]
|
let song = songlink.body.entitiesByUniqueId[songlink.body.entityUniqueId]
|
||||||
|
|
||||||
|
// YT Playlist thumbnails don't work properly
|
||||||
|
if(songlink.body.entityUniqueId.startsWith("YOUTUBE_PLAYLIST") && Object.keys(songlink.body.entitiesByUniqueId).length >= 2){
|
||||||
|
song.thumbnailUrl = songlink.body.entitiesByUniqueId[Object.keys(songlink.body.entitiesByUniqueId).filter((k)=>!k.startsWith("YOUTUBE_PLAYLIST"))[0]].thumbnailUrl
|
||||||
|
}
|
||||||
|
|
||||||
let btns = renderMusicButtons(songlink.body.linksByPlatform)
|
let btns = renderMusicButtons(songlink.body.linksByPlatform)
|
||||||
return editOrReply(context, {embeds:[
|
return editOrReply(context, {embeds:[
|
||||||
createEmbed("default", context, {
|
createEmbed("defaultNoFooter", context, {
|
||||||
author: {
|
author: {
|
||||||
name: `${song.title} by ${song.artistName}`.substr(0,1000),
|
name: `${song.title} by ${song.artistName}`.substr(0,1000),
|
||||||
iconUrl: song.thumbnailUrl,
|
iconUrl: song.thumbnailUrl,
|
||||||
url: urls[0]
|
url: urls[0]
|
||||||
},
|
|
||||||
footer: {
|
|
||||||
text: `powered by song.link • ${context.application.name}`
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
], components: btns })
|
], components: btns })
|
||||||
}catch(e){
|
}catch(e){
|
||||||
|
console.log(e)
|
||||||
return editOrReply(context, createEmbed("warning", context, "No results found."))
|
return editOrReply(context, createEmbed("warning", context, "No results found."))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -41,23 +41,27 @@ module.exports = {
|
||||||
})
|
})
|
||||||
let song = songlink.body.entitiesByUniqueId[songlink.body.entityUniqueId]
|
let song = songlink.body.entitiesByUniqueId[songlink.body.entityUniqueId]
|
||||||
|
|
||||||
|
// YT Playlist thumbnails don't work properly
|
||||||
|
if(songlink.body.entityUniqueId.startsWith("YOUTUBE_PLAYLIST") && Object.keys(songlink.body.entitiesByUniqueId).length >= 2){
|
||||||
|
song.thumbnailUrl = songlink.body.entitiesByUniqueId[Object.keys(songlink.body.entitiesByUniqueId).filter((k)=>!k.startsWith("YOUTUBE_PLAYLIST"))[0]].thumbnailUrl
|
||||||
|
}
|
||||||
|
|
||||||
let btns = renderMusicButtons(songlink.body.linksByPlatform)
|
let btns = renderMusicButtons(songlink.body.linksByPlatform)
|
||||||
return editOrReply(context, {
|
return editOrReply(context, {
|
||||||
embeds: [
|
embeds: [
|
||||||
createEmbed("default", context, {
|
createEmbed("defaultNoFooter", context, {
|
||||||
author: {
|
author: {
|
||||||
name: `${song.title} by ${song.artistName}`.substr(0, 1000),
|
name: `${song.title} by ${song.artistName}`.substr(0, 1000),
|
||||||
iconUrl: song.thumbnailUrl,
|
iconUrl: song.thumbnailUrl,
|
||||||
url: urls[0]
|
url: urls[0]
|
||||||
},
|
}
|
||||||
footer: {}
|
|
||||||
})
|
})
|
||||||
], components: btns
|
], components: btns
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e)
|
console.log(e)
|
||||||
return editOrReply(context, createEmbed("error", context, `Unable to perform song search.`))
|
return editOrReply(context, createEmbed("warning", context, `No results found.`))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
Loading…
Add table
Add a link
Reference in a new issue