Merge branch 'main' of https://github.com/aiko-chan-ai/discord.js-selfbot-v13
This commit is contained in:
commit
a6b34dcff3
@ -359,22 +359,25 @@ class Player extends EventEmitter {
|
|||||||
if (!this._currentResourceAudio) throw new Error('No current resource audio');
|
if (!this._currentResourceAudio) throw new Error('No current resource audio');
|
||||||
this._stop(false, this.options.leaveOnStop);
|
this._stop(false, this.options.leaveOnStop);
|
||||||
}
|
}
|
||||||
|
_reset(){
|
||||||
|
this._currentTime = 0;
|
||||||
|
this._currentResourceAudio = null;
|
||||||
|
this._playingTime = 0;
|
||||||
|
this.isPlaying = false;
|
||||||
|
this._player.stop();
|
||||||
|
}
|
||||||
_stop(finish = false, force = false) {
|
_stop(finish = false, force = false) {
|
||||||
if (!this._currentResourceAudio) return;
|
if (!this._currentResourceAudio) return;
|
||||||
this._queue.reset();
|
this._queue.reset();
|
||||||
this._previousSongs.reset();
|
this._previousSongs.reset();
|
||||||
this._timeoutEmpty = undefined;
|
this._timeoutEmpty = undefined;
|
||||||
this._player.stop();
|
this._reset();
|
||||||
this._currentTime = 0;
|
if (force || finish && this.options.leaveOnFinish) this.currentConnection?.destroy();
|
||||||
this._currentResourceAudio = null;
|
|
||||||
this._playingTime = 0;
|
|
||||||
this.isPlaying = false;
|
|
||||||
this.channel = null;
|
this.channel = null;
|
||||||
this.guild = null;
|
this.guild = null;
|
||||||
this.song = null;
|
this.song = null;
|
||||||
this.volume = 100;
|
this.volume = 100;
|
||||||
this.loopMode = 0;
|
this.loopMode = 0;
|
||||||
if (force || !finish && this.options.leaveOnStop || finish && this.options.leaveOnFinish) this.currentConnection?.destroy();
|
|
||||||
this.message = null;
|
this.message = null;
|
||||||
}
|
}
|
||||||
skip() {
|
skip() {
|
||||||
@ -403,6 +406,9 @@ class Player extends EventEmitter {
|
|||||||
}
|
}
|
||||||
async previous() {
|
async previous() {
|
||||||
if (!this._previousSongs.length) throw new Error('No previous songs');
|
if (!this._previousSongs.length) throw new Error('No previous songs');
|
||||||
|
const currentSong = this.song;
|
||||||
|
// add to queue
|
||||||
|
this._queue.enqueue(currentSong);
|
||||||
const previousSong = this._previousSongs.pop();
|
const previousSong = this._previousSongs.pop();
|
||||||
this.song = previousSong;
|
this.song = previousSong;
|
||||||
await this.createStream(this.song.url);
|
await this.createStream(this.song.url);
|
||||||
@ -508,8 +514,8 @@ class Player extends EventEmitter {
|
|||||||
_privateEvent() {
|
_privateEvent() {
|
||||||
this.on('next_song', async () => {
|
this.on('next_song', async () => {
|
||||||
await this._skip().catch(() => {
|
await this._skip().catch(() => {
|
||||||
this.emit(Event.FINISH, this.message);
|
if (this.message) this.emit(Event.FINISH, this.message);
|
||||||
this._stop(true);
|
this._reset();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user