From da0b85077ba88443aea51a50d782073b6fe8c6e5 Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Sun, 20 Jun 2021 12:42:17 +0545 Subject: [PATCH] feat: seek --- src/Structures/Queue.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Structures/Queue.ts b/src/Structures/Queue.ts index 588976b..c5c2e6d 100644 --- a/src/Structures/Queue.ts +++ b/src/Structures/Queue.ts @@ -254,6 +254,20 @@ class Queue { }); } + async seek(position: number) { + if (!this.playing || !this.current) return false; + if (position < 1) position = 0; + if (position >= this.current.durationMS) return this.skip(); + + await this.play(this.current, { + immediate: true, + filtersUpdate: true, // to stop events + seek: position + }); + + return true; + } + /** * Plays previous track * @returns {Promise}