mirror of
https://gitlab.com/bignutty/labscore.git
synced 2025-06-09 06:33:05 -04:00
remove audio detection because nobody uses it anyways
This commit is contained in:
parent
d8ab4e1810
commit
896ac7d400
3 changed files with 22 additions and 71 deletions
|
@ -13,85 +13,43 @@ module.exports = {
|
|||
name: 'audio',
|
||||
aliases: ['aud'],
|
||||
metadata: {
|
||||
description: '**Audio Detection**\nUsing the audio command without replying to a message will try to identify the song in the most recent video in chat.\n\n**Music Platform Links**\n__Replying__ to a message while using this command will return a list of music platforms the provided music (link) is available on.',
|
||||
description_short: 'Audio detection',
|
||||
description: '__Replying__ to a message while using this command will return a list of music streamin platforms the provided song (link) is available on.',
|
||||
description_short: 'Cross-platform music search',
|
||||
examples: ['aud'],
|
||||
category: 'search',
|
||||
usage: 'audio'
|
||||
},
|
||||
run: async (context) => {
|
||||
context.triggerTyping();
|
||||
try{
|
||||
|
||||
if(context.message.messageReference){
|
||||
let msg;
|
||||
try{
|
||||
msg = await context.message.channel.fetchMessage(context.message.messageReference.messageId)
|
||||
} catch(e){
|
||||
return editOrReply(context, {embeds:[createEmbed("error", context, "Unable to fetch message.")]})
|
||||
}
|
||||
let urls = msg.content.match(urlr)
|
||||
if(urls){
|
||||
try{
|
||||
let songlink = await superagent.get(`https://api.song.link/v1-alpha.1/links?url=${encodeURIComponent(urls[0])}`)
|
||||
let song = songlink.body.entitiesByUniqueId[songlink.body.entityUniqueId]
|
||||
|
||||
let btns = renderMusicButtons(songlink.body.linksByPlatform)
|
||||
return editOrReply(context, {embeds:[
|
||||
createEmbed("default", context, {
|
||||
author: {
|
||||
name: `${song.title} by ${song.artistName}`.substr(0,1000),
|
||||
iconUrl: song.thumbnailUrl,
|
||||
url: urls[0]
|
||||
},
|
||||
footer: {}
|
||||
})
|
||||
], components: btns})
|
||||
}catch(e){} //ignore it and run the audio detection flow
|
||||
}
|
||||
if (!context.message.messageReference) return editOrReply(context, { embeds: [createEmbed("warning", context, "You need to reply to a message containing a song link.")] })
|
||||
try {
|
||||
let msg;
|
||||
try {
|
||||
msg = await context.message.channel.fetchMessage(context.message.messageReference.messageId)
|
||||
} catch (e) {
|
||||
return editOrReply(context, { embeds: [createEmbed("error", context, "Unable to fetch message.")] })
|
||||
}
|
||||
let urls = msg.content.match(urlr)
|
||||
if (urls) {
|
||||
let songlink = await superagent.get(`https://api.song.link/v1-alpha.1/links?url=${encodeURIComponent(urls[0])}`)
|
||||
let song = songlink.body.entitiesByUniqueId[songlink.body.entityUniqueId]
|
||||
|
||||
|
||||
let audios = await getRecentVideo(context, 50)
|
||||
if(!audios.length) return editOrReply(context, {embeds:[createEmbed("warning", context, `Could not find supported video.`)]})
|
||||
let audioSearch = await searchAudio(context, audios[0].url)
|
||||
search = audioSearch.response
|
||||
if(audioSearch.response.body.status == 0){
|
||||
// API lowkey sucks, fetch more metadata via songlink
|
||||
let url = audioSearch.response.body.media[Object.keys(audioSearch.response.body.media)[0]]
|
||||
if(audioSearch.response.body.media.deezer) url = audioSearch.response.body.media.deezer
|
||||
if(audioSearch.response.body.media.napster) url = audioSearch.response.body.media.napster
|
||||
if(audioSearch.response.body.media.apple_music) url = audioSearch.response.body.media.apple_music
|
||||
if(audioSearch.response.body.media.spotify) url = audioSearch.response.body.media.spotify
|
||||
try{
|
||||
let songlink = await superagent.get(`https://api.song.link/v1-alpha.1/links?url=${encodeURIComponent(url)}`)
|
||||
//get song meta
|
||||
let song = songlink.body.entitiesByUniqueId[songlink.body.entityUniqueId]
|
||||
|
||||
let btns = renderMusicButtons(songlink.body.linksByPlatform)
|
||||
return editOrReply(context, {embeds:[
|
||||
let btns = renderMusicButtons(songlink.body.linksByPlatform)
|
||||
return editOrReply(context, {
|
||||
embeds: [
|
||||
createEmbed("default", context, {
|
||||
author: {
|
||||
name: `${song.title} by ${song.artistName}`.substr(0,1000),
|
||||
name: `${song.title} by ${song.artistName}`.substr(0, 1000),
|
||||
iconUrl: song.thumbnailUrl,
|
||||
url: url
|
||||
url: urls[0]
|
||||
},
|
||||
footer: {}
|
||||
})
|
||||
], components: btns})
|
||||
}catch(e){
|
||||
return editOrReply(context, {embeds: [
|
||||
createEmbed("error", context, "Links for this song are unavailable..")
|
||||
]})
|
||||
}
|
||||
], components: btns
|
||||
})
|
||||
}
|
||||
|
||||
}catch(e){
|
||||
if(e.response?.body?.status){
|
||||
return editOrReply(context, {embeds:[createEmbed("error", context, e.response.body.message)]})
|
||||
}
|
||||
console.log(e)
|
||||
return editOrReply(context, {embeds:[createEmbed("error", context, `Unable to perform audio search.`)]})
|
||||
} catch (e) {
|
||||
return editOrReply(context, { embeds: [createEmbed("error", context, `Unable to perform song search.`)] })
|
||||
}
|
||||
},
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue