better paused status

This commit is contained in:
Snowflake107 2021-06-13 16:13:02 +05:45
parent 9e3b66ee8a
commit 580f4aa9c6

View file

@ -29,7 +29,6 @@ class BasicStreamDispatcher extends EventEmitter<VoiceEvents> {
public readonly channel: VoiceChannel | StageChannel; public readonly channel: VoiceChannel | StageChannel;
public connectPromise?: Promise<void>; public connectPromise?: Promise<void>;
public audioResource?: AudioResource<Track>; public audioResource?: AudioResource<Track>;
public paused = false;
constructor(connection: VoiceConnection, channel: VoiceChannel | StageChannel) { constructor(connection: VoiceConnection, channel: VoiceChannel | StageChannel) {
super(); super();
@ -118,13 +117,11 @@ class BasicStreamDispatcher extends EventEmitter<VoiceEvents> {
pause(interpolateSilence?: boolean) { pause(interpolateSilence?: boolean) {
const success = this.audioPlayer.pause(interpolateSilence); const success = this.audioPlayer.pause(interpolateSilence);
this.paused = success;
return success; return success;
} }
resume() { resume() {
const success = this.audioPlayer.unpause(); const success = this.audioPlayer.unpause();
this.paused = !success;
return success; return success;
} }
@ -159,6 +156,10 @@ class BasicStreamDispatcher extends EventEmitter<VoiceEvents> {
if (!this.audioResource) return 0; if (!this.audioResource) return 0;
return this.audioResource.playbackDuration; return this.audioResource.playbackDuration;
} }
get paused() {
return [AudioPlayerStatus.AutoPaused, AudioPlayerStatus.Paused].includes(this.audioPlayer.state.status)
}
} }
export { BasicStreamDispatcher as StreamDispatcher }; export { BasicStreamDispatcher as StreamDispatcher };