From 0a61d865ff89e715ebfee336a46baead286de636 Mon Sep 17 00:00:00 2001 From: Dragory <2606411+Dragory@users.noreply.github.com> Date: Tue, 26 Oct 2021 12:34:18 +0300 Subject: [PATCH] feat: remove monkeypatched d.js debug code --- backend/src/index.ts | 34 ---------------------------------- 1 file changed, 34 deletions(-) diff --git a/backend/src/index.ts b/backend/src/index.ts index a1994cbf..0888bccd 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -185,40 +185,6 @@ setInterval(() => { logger.info("Connecting to database"); connect().then(async () => { - const RequestHandler = require("discord.js/src/rest/RequestHandler.js"); - const originalPush = RequestHandler.prototype.push; - // tslint:disable-next-line:only-arrow-functions - RequestHandler.prototype.push = function (...args) { - const request = args[0]; - logRestCall(request.method, request.path); - return originalPush.call(this, ...args); - }; - - let globalRateLimits = 0; - const rateLimitsByType: Record = {}; - - const originalOnRateLimit = RequestHandler.prototype.onRateLimit; - // tslint:disable-next-line:only-arrow-functions - RequestHandler.prototype.onRateLimit = function (...args) { - const [request, limit, timeout, isGlobal] = args; - if (isGlobal) { - globalRateLimits++; - } else { - const name = `${request.method} ${request.route}`; - rateLimitsByType[name] = rateLimitsByType[name] ?? 0; - rateLimitsByType[name]++; - } - return originalOnRateLimit.call(this, ...args); - }; - - setInterval(() => { - const topSortedEntries = Object.entries(rateLimitsByType) - .sort((a, b) => (a[1] > b[1] ? -1 : 1)) - .slice(0, 5); - console.log(`[RATE LIMIT DEBUG] Total global rate limit (50/s) hits: ${globalRateLimits}`); - console.log(`[RATE LIMIT DEBUG] Top non-global rate limit hits: ${JSON.stringify(topSortedEntries, null, 2)}`); - }, 5 * 60 * 1000); - const client = new Client({ partials: ["USER", "CHANNEL", "GUILD_MEMBER", "MESSAGE", "REACTION"],