From 78dafb9480e9c1d8dcc505c89d928c90a07bce0b Mon Sep 17 00:00:00 2001 From: Programmix Date: Mon, 30 Jan 2017 13:38:47 -0800 Subject: [PATCH] Properly check whether an Opus engine exists (#1150) * Properly check whether an Opus engine exists I think I'm retarded * Fix eslint error * Update OpusEngineList.js --- src/client/voice/opus/OpusEngineList.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/client/voice/opus/OpusEngineList.js b/src/client/voice/opus/OpusEngineList.js index bc9fe6102..2aa7f17fc 100644 --- a/src/client/voice/opus/OpusEngineList.js +++ b/src/client/voice/opus/OpusEngineList.js @@ -3,6 +3,8 @@ const list = [ require('./OpusScriptEngine'), ]; +let opusEngineFound; + function fetch(Encoder) { try { return new Encoder(); @@ -24,5 +26,6 @@ exports.fetch = () => { }; exports.guaranteeOpusEngine = () => { - if (!this.opusEncoder) throw new Error('Couldn\'t find an Opus engine.'); + if (typeof opusEngineFound === 'undefined') opusEngineFound = Boolean(exports.fetch()); + if (!opusEngineFound) throw new Error('Couldn\'t find an Opus engine.'); };