mirror of
https://gitlab.com/bignutty/labscore.git
synced 2025-06-08 14:13:02 -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',
|
name: 'audio',
|
||||||
aliases: ['aud'],
|
aliases: ['aud'],
|
||||||
metadata: {
|
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: '__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: 'Audio detection',
|
description_short: 'Cross-platform music search',
|
||||||
examples: ['aud'],
|
examples: ['aud'],
|
||||||
category: 'search',
|
category: 'search',
|
||||||
usage: 'audio'
|
usage: 'audio'
|
||||||
},
|
},
|
||||||
run: async (context) => {
|
run: async (context) => {
|
||||||
context.triggerTyping();
|
context.triggerTyping();
|
||||||
try{
|
if (!context.message.messageReference) return editOrReply(context, { embeds: [createEmbed("warning", context, "You need to reply to a message containing a song link.")] })
|
||||||
|
try {
|
||||||
if(context.message.messageReference){
|
let msg;
|
||||||
let msg;
|
try {
|
||||||
try{
|
msg = await context.message.channel.fetchMessage(context.message.messageReference.messageId)
|
||||||
msg = await context.message.channel.fetchMessage(context.message.messageReference.messageId)
|
} catch (e) {
|
||||||
} catch(e){
|
return editOrReply(context, { embeds: [createEmbed("error", context, "Unable to fetch message.")] })
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
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 btns = renderMusicButtons(songlink.body.linksByPlatform)
|
||||||
let audios = await getRecentVideo(context, 50)
|
return editOrReply(context, {
|
||||||
if(!audios.length) return editOrReply(context, {embeds:[createEmbed("warning", context, `Could not find supported video.`)]})
|
embeds: [
|
||||||
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:[
|
|
||||||
createEmbed("default", context, {
|
createEmbed("default", 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: url
|
url: urls[0]
|
||||||
},
|
},
|
||||||
footer: {}
|
footer: {}
|
||||||
})
|
})
|
||||||
], components: btns})
|
], components: btns
|
||||||
}catch(e){
|
})
|
||||||
return editOrReply(context, {embeds: [
|
|
||||||
createEmbed("error", context, "Links for this song are unavailable..")
|
|
||||||
]})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
}catch(e){
|
return editOrReply(context, { embeds: [createEmbed("error", context, `Unable to perform song search.`)] })
|
||||||
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.`)]})
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
|
@ -25,7 +25,6 @@ const Api = Object.freeze({
|
||||||
PHOTOFUNIA_RETRO_WAVE: '/photofunia/retro-wave',
|
PHOTOFUNIA_RETRO_WAVE: '/photofunia/retro-wave',
|
||||||
PHOTOFUNIA_YACHT: '/photofunia/yacht',
|
PHOTOFUNIA_YACHT: '/photofunia/yacht',
|
||||||
|
|
||||||
SEARCH_AUDIO: '/search/audio',
|
|
||||||
SEARCH_BING: '/search/bing',
|
SEARCH_BING: '/search/bing',
|
||||||
SEARCH_BING_IMAGES: '/search/bing-images',
|
SEARCH_BING_IMAGES: '/search/bing-images',
|
||||||
SEARCH_DICTIONARY: '/search/dictionary',
|
SEARCH_DICTIONARY: '/search/dictionary',
|
||||||
|
|
|
@ -92,12 +92,6 @@ module.exports.googleVisionWebDetection = async function(context, url){
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.searchAudio = async function(context, url){
|
|
||||||
return await request(Api.SEARCH_AUDIO, "GET", {}, {
|
|
||||||
url: url
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports.lyrics = async function(context, query){
|
module.exports.lyrics = async function(context, query){
|
||||||
return await request(Api.SEARCH_LYRICS, "GET", {}, {
|
return await request(Api.SEARCH_LYRICS, "GET", {}, {
|
||||||
q: query
|
q: query
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue