From 6d92f70bb6f84c77c7bc6271e99f00e1c86582ee Mon Sep 17 00:00:00 2001 From: Cinnamon <71698422+aiko-chan-ai@users.noreply.github.com> Date: Sun, 11 Sep 2022 10:06:34 +0700 Subject: [PATCH 1/2] Update VoiceCall.md --- Document/VoiceCall.md | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/Document/VoiceCall.md b/Document/VoiceCall.md index ce4f749..a9eaffa 100644 --- a/Document/VoiceCall.md +++ b/Document/VoiceCall.md @@ -66,7 +66,7 @@ let i = setInterval(() => { ```js /* Copyright aiko-chan-ai @2022. All rights reserved. */ const DjsVoice = require('@discordjs/voice'); -const Discord = require('discord.js-selfbot-v13'); +const Discord = require('./mymodule/src/index.js'); // require('discord.js-selfbot-v13'); const playDL = require('play-dl'); const EventEmitter = require('events'); const Event = { @@ -359,22 +359,25 @@ class Player extends EventEmitter { if (!this._currentResourceAudio) throw new Error('No current resource audio'); 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) { if (!this._currentResourceAudio) return; this._queue.reset(); this._previousSongs.reset(); this._timeoutEmpty = undefined; - this._player.stop(); - this._currentTime = 0; - this._currentResourceAudio = null; - this._playingTime = 0; - this.isPlaying = false; + this._reset(); + if (force || finish && this.options.leaveOnFinish) this.currentConnection?.destroy(); this.channel = null; this.guild = null; this.song = null; this.volume = 100; this.loopMode = 0; - if (force || !finish && this.options.leaveOnStop || finish && this.options.leaveOnFinish) this.currentConnection?.destroy(); this.message = null; } skip() { @@ -403,6 +406,9 @@ class Player extends EventEmitter { } async previous() { 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(); this.song = previousSong; await this.createStream(this.song.url); @@ -508,8 +514,8 @@ class Player extends EventEmitter { _privateEvent() { this.on('next_song', async () => { await this._skip().catch(() => { - this.emit(Event.FINISH, this.message); - this._stop(true); + if (this.message) this.emit(Event.FINISH, this.message); + this._reset(); }); }); } @@ -619,4 +625,4 @@ queue: Song[]; previousSongs: Song[]; loopMode = 0; */ -``` \ No newline at end of file +``` From 9d7228bf84b8646a6c50aa9c1076b0e3ed0e4c09 Mon Sep 17 00:00:00 2001 From: Cinnamon <71698422+aiko-chan-ai@users.noreply.github.com> Date: Sun, 11 Sep 2022 10:12:30 +0700 Subject: [PATCH 2/2] Update VoiceCall.md --- Document/VoiceCall.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Document/VoiceCall.md b/Document/VoiceCall.md index a9eaffa..a75f2ab 100644 --- a/Document/VoiceCall.md +++ b/Document/VoiceCall.md @@ -66,7 +66,7 @@ let i = setInterval(() => { ```js /* Copyright aiko-chan-ai @2022. All rights reserved. */ const DjsVoice = require('@discordjs/voice'); -const Discord = require('./mymodule/src/index.js'); // require('discord.js-selfbot-v13'); +const Discord = require('discord.js-selfbot-v13'); const playDL = require('play-dl'); const EventEmitter = require('events'); const Event = {