Compare commits
No commits in common. "689821dd0203c7faf096067e86e9e20bf0498abe" and "7ebc2b93b8bc57f80ef058a5464a9f18f199199c" have entirely different histories.
689821dd02
...
7ebc2b93b8
|
@ -36,24 +36,8 @@ class GuildsManager {
|
|||
if (!this.#guilds[guild_id]?.[guild_action.target]?.[guild_action.action]) {
|
||||
message.channel.send(`The command ${guild_action.target} ${guild_action.action} is not implemented yet`)
|
||||
} else {
|
||||
try {
|
||||
const output = await this.#guilds[guild_id][guild_action.target][guild_action.action](guild_action)
|
||||
return output
|
||||
} catch (e) {
|
||||
const error_message = await message.channel.send(":warning: Something went wrong. React with :eyes: to get more information about this error.")
|
||||
error_message.react("👀")
|
||||
error_message.awaitReactions((r, u) => r.emoji.name === "👀" && u.id !== error_message.author.id, {max: 1})
|
||||
.then(() => {
|
||||
message.channel.send(`Target manager: **${guild_action.target}** Action: **${guild_action.action}** Parameters: **${guild_action.params.join(', ')}**`
|
||||
+ "\n"
|
||||
+ `Original message: \`${guild_action.message}\``
|
||||
+ "\n"
|
||||
+ "```js\n"
|
||||
+ e.stack
|
||||
+ "\n```")
|
||||
})
|
||||
return null
|
||||
}
|
||||
const output = await this.#guilds[guild_id][guild_action.target][guild_action.action](guild_action)
|
||||
return output
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,21 +15,26 @@ class Youtube {
|
|||
* @return {Track[]} An array of objects representing the search results. <code>source</code> is set to <code>"youtube"</code>
|
||||
*/
|
||||
async search_track(search) {
|
||||
const req = await fetch('https://www.youtube.com/results?search_query='
|
||||
+ encodeURIComponent(search))
|
||||
const body = await req.text()
|
||||
const json = JSON.parse(body.match(/ytInitialData = (.*);<\/script>/)[1])
|
||||
const results = json.contents.twoColumnSearchResultsRenderer.primaryContents.sectionListRenderer.contents[0].itemSectionRenderer.contents
|
||||
return results
|
||||
.filter(e => e.videoRenderer)
|
||||
.map(e => {
|
||||
return new Track({
|
||||
url: 'https://www.youtube.com/watch?v=' + e.videoRenderer.videoId,
|
||||
title: e.videoRenderer.title.runs[0].text,
|
||||
length: e.videoRenderer.lengthText.simpleText,
|
||||
source: 'youtube',
|
||||
try {
|
||||
const req = await fetch('https://www.youtube.com/results?search_query='
|
||||
+ encodeURIComponent(search))
|
||||
const body = await req.text()
|
||||
const json = JSON.parse(body.match(/ytInitialData = (.*);<\/script>/)[1])
|
||||
const results = json.contents.twoColumnSearchResultsRenderer.primaryContents.sectionListRenderer.contents[0].itemSectionRenderer.contents
|
||||
return results
|
||||
.filter(e => e.videoRenderer)
|
||||
.map(e => {
|
||||
return new Track({
|
||||
url: 'https://www.youtube.com/watch?v=' + e.videoRenderer.videoId,
|
||||
title: e.videoRenderer.title.runs[0].text,
|
||||
length: e.videoRenderer.lengthText.simpleText,
|
||||
source: 'youtube',
|
||||
})
|
||||
})
|
||||
})
|
||||
} catch(e) {
|
||||
console.error(e)
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue