From 6d11713ed6a246fbb7b5315b34eeed838d636e1e Mon Sep 17 00:00:00 2001 From: Shadow Date: Tue, 5 Apr 2022 20:30:26 -0500 Subject: [PATCH] Fix raw routes not being used --- src/AmariBot.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/AmariBot.js b/src/AmariBot.js index 52d4528..dd84eee 100644 --- a/src/AmariBot.js +++ b/src/AmariBot.js @@ -13,6 +13,7 @@ class AmariBot { * @param {boolean} [options.debug=false] - Controls whether debug mode is enabled for the library * @param {string} [options.baseURL="https://amaribot.com/api/"] - The base URL for the API requests, defaults to the amaribot.com API * @param {string} [options.version="v1"] - The base URL for the API requests, defaults v1 + * @param {string} [options.rawRoutes=false] - Whether regular leaderboard routes should always return the raw form or not, useful for debugging */ constructor(token, options = {}) { if (typeof token !== "string") throw new TypeError("The API token must be a string") @@ -21,12 +22,14 @@ class AmariBot { if (options.baseURL !== undefined && !options.baseURL.endsWith("/")) throw new Error("baseURL must end with a /") if (options.version !== undefined && typeof options.version !== "string") throw new TypeError("version must be a string") if (options.debug !== undefined && typeof options.debug !== "boolean") throw new TypeError("options.debug must be a boolean") + if (options.rawRoutes !== undefined && typeof options.rawRoutes !== "boolean") throw new TypeError("options.rawRoutes must be a boolean") this.token = token this.debug = options.debug || false this.baseURL = options.baseURL || "https://amaribot.com/api/" this.version = options.version || "v1" this.requestHandler = new RequestHandler(this) + this.rawRoutes = options.rawRoutes || false if (this.debug) console.debug("amaribot.js initalized\n" + JSON.stringify(options, null, 2)) } @@ -80,7 +83,7 @@ class AmariBot { if (options.limit !== undefined && typeof options.limit !== "number") throw new TypeError("options.limit must be a number") if (options.page !== undefined && typeof options.page !== "number") throw new TypeError("options.page must be a number") - const data = await this._request(`/guild/leaderboard/${guildId}`, options) + const data = await this._request(`/guild/${this.rawRoutes ? "raw/" : ""}leaderboard/${guildId}`, options) data.id = guildId return new Leaderboard(data) }