fix(Player): fix soundcloud
This commit is contained in:
parent
7241b46c07
commit
6d9d427e4e
1 changed files with 4 additions and 7 deletions
|
@ -10,9 +10,7 @@ import { Util } from "./utils/Util";
|
||||||
import Spotify from "spotify-url-info";
|
import Spotify from "spotify-url-info";
|
||||||
import { PlayerError, ErrorStatusCode } from "./Structures/PlayerError";
|
import { PlayerError, ErrorStatusCode } from "./Structures/PlayerError";
|
||||||
import { getInfo as ytdlGetInfo } from "ytdl-core";
|
import { getInfo as ytdlGetInfo } from "ytdl-core";
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
import { Client as SoundCloud, SearchResult as SoundCloudSearchResult } from "soundcloud-scraper";
|
||||||
// @ts-ignore
|
|
||||||
import { Client as SoundCloud } from "soundcloud-scraper";
|
|
||||||
import { Playlist } from "./Structures/Playlist";
|
import { Playlist } from "./Structures/Playlist";
|
||||||
import { ExtractorModel } from "./Structures/ExtractorModel";
|
import { ExtractorModel } from "./Structures/ExtractorModel";
|
||||||
import { generateDependencyReport } from "@discordjs/voice";
|
import { generateDependencyReport } from "@discordjs/voice";
|
||||||
|
@ -270,8 +268,7 @@ class Player extends EventEmitter<PlayerEvents> {
|
||||||
}
|
}
|
||||||
case QueryType.SOUNDCLOUD_TRACK:
|
case QueryType.SOUNDCLOUD_TRACK:
|
||||||
case QueryType.SOUNDCLOUD_SEARCH: {
|
case QueryType.SOUNDCLOUD_SEARCH: {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-empty-function
|
const result: SoundCloudSearchResult[] = QueryResolver.resolve(query) === QueryType.SOUNDCLOUD_TRACK ? [{ url: query }] : await soundcloud.search(query, "track").catch(() => []);
|
||||||
const result: any[] = QueryResolver.resolve(query) === QueryType.SOUNDCLOUD_TRACK ? [{ url: query }] : await soundcloud.search(query, "track").catch(Util.noop);
|
|
||||||
if (!result || !result.length) return { playlist: null, tracks: [] };
|
if (!result || !result.length) return { playlist: null, tracks: [] };
|
||||||
const res: Track[] = [];
|
const res: Track[] = [];
|
||||||
|
|
||||||
|
@ -385,7 +382,7 @@ class Player extends EventEmitter<PlayerEvents> {
|
||||||
return { playlist: playlist, tracks: playlist.tracks };
|
return { playlist: playlist, tracks: playlist.tracks };
|
||||||
}
|
}
|
||||||
case QueryType.SOUNDCLOUD_PLAYLIST: {
|
case QueryType.SOUNDCLOUD_PLAYLIST: {
|
||||||
const data = await SoundCloud.getPlaylist(query).catch(Util.noop);
|
const data = await soundcloud.getPlaylist(query).catch(Util.noop);
|
||||||
if (!data) return { playlist: null, tracks: [] };
|
if (!data) return { playlist: null, tracks: [] };
|
||||||
|
|
||||||
const res = new Playlist(this, {
|
const res = new Playlist(this, {
|
||||||
|
@ -404,7 +401,7 @@ class Player extends EventEmitter<PlayerEvents> {
|
||||||
rawPlaylist: data
|
rawPlaylist: data
|
||||||
});
|
});
|
||||||
|
|
||||||
for (const song of data) {
|
for (const song of data.tracks) {
|
||||||
const track = new Track(this, {
|
const track = new Track(this, {
|
||||||
title: song.title,
|
title: song.title,
|
||||||
description: song.description ?? "",
|
description: song.description ?? "",
|
||||||
|
|
Loading…
Reference in a new issue