Skip to content

Commit

Permalink
Fix raw routes not being used
Browse files Browse the repository at this point in the history
  • Loading branch information
thewilloftheshadow authored Apr 6, 2022
1 parent 7ef1280 commit 6d11713
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/AmariBot.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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))
}
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 6d11713

Please sign in to comment.