fix: autoplay
This commit is contained in:
parent
ed92e332ab
commit
a0b04d7a62
3 changed files with 21 additions and 17 deletions
|
@ -15,6 +15,7 @@
|
|||
"@typescript-eslint/explicit-module-boundary-types": "off",
|
||||
"@typescript-eslint/no-unused-vars": "error",
|
||||
"@typescript-eslint/no-explicit-any": "error",
|
||||
"@typescript-eslint/ban-ts-comment": "error"
|
||||
"@typescript-eslint/ban-ts-comment": "error",
|
||||
"semi": "error"
|
||||
}
|
||||
}
|
|
@ -196,7 +196,7 @@ class Player extends EventEmitter<PlayerEvents> {
|
|||
case QueryType.YOUTUBE_SEARCH: {
|
||||
const videos = await YouTube.search(query, {
|
||||
type: "video"
|
||||
}).catch(Util.noop); // eslint-disable-line @typescript-eslint/no-empty-function
|
||||
}).catch(Util.noop);
|
||||
if (!videos) return { playlist: null, tracks: [] };
|
||||
|
||||
const tracks = videos.map((m) => {
|
||||
|
@ -224,7 +224,7 @@ class Player extends EventEmitter<PlayerEvents> {
|
|||
const res: Track[] = [];
|
||||
|
||||
for (const r of result) {
|
||||
const trackInfo = await soundcloud.getSongInfo(r.url).catch(Util.noop); // eslint-disable-line @typescript-eslint/no-empty-function
|
||||
const trackInfo = await soundcloud.getSongInfo(r.url).catch(Util.noop);
|
||||
if (!trackInfo) continue;
|
||||
|
||||
const track = new Track(this, {
|
||||
|
@ -246,7 +246,7 @@ class Player extends EventEmitter<PlayerEvents> {
|
|||
return { playlist: null, tracks: res };
|
||||
}
|
||||
case QueryType.SPOTIFY_SONG: {
|
||||
const spotifyData = await Spotify.getData(query).catch(Util.noop); // eslint-disable-line @typescript-eslint/no-empty-function
|
||||
const spotifyData = await Spotify.getData(query).catch(Util.noop);
|
||||
if (!spotifyData) return { playlist: null, tracks: [] };
|
||||
const spotifyTrack = new Track(this, {
|
||||
title: spotifyData.name,
|
||||
|
@ -267,7 +267,7 @@ class Player extends EventEmitter<PlayerEvents> {
|
|||
}
|
||||
case QueryType.SPOTIFY_PLAYLIST:
|
||||
case QueryType.SPOTIFY_ALBUM: {
|
||||
const spotifyPlaylist = await Spotify.getData(query).catch(Util.noop); // eslint-disable-line @typescript-eslint/no-empty-function
|
||||
const spotifyPlaylist = await Spotify.getData(query).catch(Util.noop);
|
||||
if (!spotifyPlaylist) return { playlist: null, tracks: [] };
|
||||
|
||||
const playlist = new Playlist(this, {
|
||||
|
@ -333,7 +333,7 @@ class Player extends EventEmitter<PlayerEvents> {
|
|||
return { playlist: playlist, tracks: playlist.tracks };
|
||||
}
|
||||
case QueryType.SOUNDCLOUD_PLAYLIST: {
|
||||
const data = await SoundCloud.getPlaylist(query).catch(Util.noop); // eslint-disable-line @typescript-eslint/no-empty-function
|
||||
const data = await SoundCloud.getPlaylist(query).catch(Util.noop);
|
||||
if (!data) return { playlist: null, tracks: [] };
|
||||
|
||||
const res = new Playlist(this, {
|
||||
|
@ -372,11 +372,11 @@ class Player extends EventEmitter<PlayerEvents> {
|
|||
return { playlist: res, tracks: res.tracks };
|
||||
}
|
||||
case QueryType.YOUTUBE_PLAYLIST: {
|
||||
const ytpl = await YouTube.getPlaylist(query).catch(Util.noop); // eslint-disable-line @typescript-eslint/no-empty-function
|
||||
const ytpl = await YouTube.getPlaylist(query).catch(Util.noop);
|
||||
if (!ytpl) return { playlist: null, tracks: [] };
|
||||
|
||||
// @todo: better way of handling large playlists
|
||||
await ytpl.fetch().catch(Util.noop); // eslint-disable-line @typescript-eslint/no-empty-function
|
||||
await ytpl.fetch().catch(Util.noop);
|
||||
|
||||
const playlist: Playlist = new Playlist(this, {
|
||||
title: ytpl.title,
|
||||
|
|
|
@ -134,7 +134,10 @@ class Queue<T = unknown> {
|
|||
});
|
||||
this.connection = connection;
|
||||
|
||||
if (channel.type === "stage") await channel.guild.me.voice.setRequestToSpeak(true).catch(Util.noop); // eslint-disable-line @typescript-eslint/no-empty-function
|
||||
if (channel.type === "stage") {
|
||||
await channel.guild.me.voice.setRequestToSpeak(true).catch(Util.noop);
|
||||
await channel.guild.me.voice.setSuppressed(false).catch(Util.noop);
|
||||
}
|
||||
|
||||
this.connection.on("error", (err) => this.player.emit("connectionError", this, err));
|
||||
this.connection.on("debug", (msg) => this.player.emit("debug", this, msg));
|
||||
|
@ -409,6 +412,7 @@ class Queue<T = unknown> {
|
|||
|
||||
if (!options.filtersUpdate) {
|
||||
this.previousTracks = this.previousTracks.filter((x) => x._trackID !== track._trackID);
|
||||
this.previousTracks.push(track);
|
||||
}
|
||||
|
||||
let stream;
|
||||
|
@ -471,10 +475,9 @@ class Queue<T = unknown> {
|
|||
if (this.options.leaveOnEnd) this.destroy();
|
||||
return void this.player.emit("queueEnd", this);
|
||||
}
|
||||
const info = await ytdl
|
||||
.getInfo(track.url)
|
||||
.then((x) => x.related_videos[0])
|
||||
.catch(Util.noop); // eslint-disable-line @typescript-eslint/no-empty-function
|
||||
const info = await YouTube.getVideo(track.url)
|
||||
.then((x) => x.videos[0])
|
||||
.catch(Util.noop);
|
||||
if (!info) {
|
||||
if (this.options.leaveOnEnd) this.destroy();
|
||||
return void this.player.emit("queueEnd", this);
|
||||
|
@ -483,11 +486,11 @@ class Queue<T = unknown> {
|
|||
const nextTrack = new Track(this.player, {
|
||||
title: info.title,
|
||||
url: `https://www.youtube.com/watch?v=${info.id}`,
|
||||
duration: info.length_seconds ? Util.buildTimeCode(Util.parseMS(info.length_seconds * 1000)) : "0:00",
|
||||
duration: info.durationFormatted ? Util.buildTimeCode(Util.parseMS(info.duration * 1000)) : "0:00",
|
||||
description: "",
|
||||
thumbnail: Util.last(info.thumbnails).url,
|
||||
views: parseInt(info.view_count.replace(/[^0-9]/g, "")),
|
||||
author: typeof info.author === "string" ? info.author : info.author.name,
|
||||
thumbnail: typeof info.thumbnail === "string" ? info.thumbnail : info.thumbnail.url,
|
||||
views: info.views,
|
||||
author: info.channel.name,
|
||||
requestedBy: track.requestedBy,
|
||||
source: "youtube"
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue