From 0619462f2cf3b97dcaffac855f53992e893e4223 Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Fri, 18 Jun 2021 00:02:55 +0545 Subject: [PATCH] Player#use & Player#unuse should return the extractor --- src/Player.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Player.ts b/src/Player.ts index e07386a..c535f39 100644 --- a/src/Player.ts +++ b/src/Player.ts @@ -399,12 +399,12 @@ class DiscordPlayer extends EventEmitter { } } - use(extractorName: string, extractor: ExtractorModel | any, force = false) { + use(extractorName: string, extractor: ExtractorModel | any, force = false): ExtractorModel { if (!extractorName) throw new Error("Cannot use unknown extractor!"); - if (this.extractors.has(extractorName) && !force) return this; + if (this.extractors.has(extractorName) && !force) return this.extractors.get(extractorName); if (extractor instanceof ExtractorModel) { this.extractors.set(extractorName, extractor); - return this; + return extractor; } for (const method of ["validate", "getInfo"]) { @@ -414,12 +414,14 @@ class DiscordPlayer extends EventEmitter { const model = new ExtractorModel(extractorName, extractor); this.extractors.set(model.name, model); - return this; + return model; } unuse(extractorName: string) { if (!this.extractors.has(extractorName)) throw new Error(`Cannot find extractor "${extractorName}"`); + const prev = this.extractors.get(extractorName); this.extractors.delete(extractorName); + return prev; } *[Symbol.iterator]() {