fix message and added other links support

This commit is contained in:
Patryk Koreń
2026-05-11 21:02:09 +02:00
parent 4fc00493af
commit a164ca433f
2 changed files with 10 additions and 6 deletions

View File

@@ -21,11 +21,10 @@ export async function requestSong(
url: string, url: string,
data: Partial<HistoryObject> data: Partial<HistoryObject>
) { ) {
getAudioFile(url).then((path) => { const path = await getAudioFile(url)
queue.songList.push({ path, url }) queue.songList.push({ path, url })
add_to_history({ url, user: data.user }) add_to_history({ url, user: data.user })
updatePlayer() await updatePlayer()
})
} }
export async function forceRequestSong( export async function forceRequestSong(

View File

@@ -18,8 +18,13 @@ export async function getAudioFile(url: string): Promise<string> {
return path return path
} }
function isYTLink(url: string) {
return url.startsWith("https://youtube") ||
url.startsWith("https://youtu.be");
}
export async function extractId(url: string): Promise<string> { export async function extractId(url: string): Promise<string> {
if (url.startsWith("https://soundcloud")) { // soundcloud if (!isYTLink(url)) {
const ytDlpBin = process.env.YT_DLP_BIN_PATH! ?? "yt-dlp"; const ytDlpBin = process.env.YT_DLP_BIN_PATH! ?? "yt-dlp";
return await new Promise<string>((resolve, reject) => { return await new Promise<string>((resolve, reject) => {
const p = spawn(ytDlpBin, [ const p = spawn(ytDlpBin, [