Skip to content

Commit

Permalink
Filter undefined message content in debug event (abalabahaha#1076)
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Hernandez authored and abalabahaha committed Nov 29, 2020
1 parent 5936086 commit 19eb558
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/rest/RequestHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,12 +259,14 @@ class RequestHandler {
}

if(resp.statusCode !== 429) {
this._client.emit("debug", `${body && body.content} ${now} ${route} ${resp.statusCode}: ${latency}ms (${this.latencyRef.latency}ms avg) | ${this.ratelimits[route].remaining}/${this.ratelimits[route].limit} left | Reset ${this.ratelimits[route].reset} (${this.ratelimits[route].reset - now}ms left)`);
const content = typeof body === "object" ? `${body.content} ` : "";
this._client.emit("debug", `${content}${now} ${route} ${resp.statusCode}: ${latency}ms (${this.latencyRef.latency}ms avg) | ${this.ratelimits[route].remaining}/${this.ratelimits[route].limit} left | Reset ${this.ratelimits[route].reset} (${this.ratelimits[route].reset - now}ms left)`);
}

if(resp.statusCode >= 300) {
if(resp.statusCode === 429) {
this._client.emit("debug", `${resp.headers["x-ratelimit-global"] ? "Global" : "Unexpected"} 429 (╯°□°)╯︵ ┻━┻: ${response}\n${body && body.content} ${now} ${route} ${resp.statusCode}: ${latency}ms (${this.latencyRef.latency}ms avg) | ${this.ratelimits[route].remaining}/${this.ratelimits[route].limit} left | Reset ${this.ratelimits[route].reset} (${this.ratelimits[route].reset - now}ms left)`);
const content = typeof body === "object" ? `${body.content} ` : "";
this._client.emit("debug", `${resp.headers["x-ratelimit-global"] ? "Global" : "Unexpected"} 429 (╯°□°)╯︵ ┻━┻: ${response}\n${content} ${now} ${route} ${resp.statusCode}: ${latency}ms (${this.latencyRef.latency}ms avg) | ${this.ratelimits[route].remaining}/${this.ratelimits[route].limit} left | Reset ${this.ratelimits[route].reset} (${this.ratelimits[route].reset - now}ms left)`);
if(retryAfter) {
setTimeout(() => {
cb();
Expand Down

0 comments on commit 19eb558

Please sign in to comment.