From 4815924279680f0e5d84ef0c6e5b5e13793df3a2 Mon Sep 17 00:00:00 2001 From: CodingKiwi Date: Wed, 28 Aug 2019 15:50:31 +0200 Subject: [PATCH] Changed var to let, updated promise check --- components/handler.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/components/handler.js b/components/handler.js index 842dd34..248e963 100644 --- a/components/handler.js +++ b/components/handler.js @@ -45,10 +45,10 @@ class Handler { const _request = this.baseRequest(url); - var received_bytes = 0; - var total_bytes = 0; + let received_bytes = 0; + let total_bytes = 0; - _request.on('response', function (data) { + _request.on('response', (data) => { total_bytes = parseInt(data.headers['content-length']); }); @@ -463,9 +463,7 @@ class Handler { const minArgs = this.options.overrides.minArgs || 5; if(args.length < minArgs) args = args.concat(this.version.minecraftArguments ? this.version.minecraftArguments.split(' ') : this.version.arguments.game); - if({}.toString.call(this.options.authorization) === "[object Promise]") { - this.options.authorization = await this.options.authorization; - } + this.options.authorization = await Promise.resolve(this.options.authorization); const fields = { '${auth_access_token}': this.options.authorization.access_token,