3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-23 09:35:02 +00:00

Add REST request/429 debugging, temporarily disable message fetch hotfix

This commit is contained in:
Dragory 2021-08-19 21:15:31 +03:00
parent c9db9608e6
commit d1d0609f7e
3 changed files with 36 additions and 12 deletions

View file

@ -22,6 +22,26 @@ import { errorMessage, isDiscordAPIError, isDiscordHTTPError, SECONDS, successMe
import { loadYamlSafely } from "./utils/loadYamlSafely";
import { DecayingCounter } from "./utils/DecayingCounter";
// === START REST DEBUG ===
import fs from "fs";
import path from "path";
const APIRequest = require("discord.js/src/rest/APIRequest.js");
const dateStr = new Date().toISOString().replace(/[:.]/g, "-");
const restDebugFile = path.join("../debug", `rest_${dateStr}.log`);
fs.writeFileSync(restDebugFile, "");
const originalMake = APIRequest.prototype.make;
// tslint:disable-next-line:only-arrow-functions
APIRequest.prototype.make = function(...args) {
const debugInfo = `${new Date().toISOString()} ${this.method.toUpperCase()} ${this.route}`;
fs.appendFileSync(restDebugFile, debugInfo + "\n", { encoding: "utf8" });
// tslint:disable-next-line:no-console
console.log(`[API REQUEST] ${this.method} ${this.route}`);
return originalMake.call(this, ...args);
};
// === END REST DEBUG ===
if (!process.env.KEY) {
// tslint:disable-next-line:no-console
console.error("Project root .env with KEY is required!");
@ -152,8 +172,8 @@ connect().then(async () => {
const client = new Client({
partials: ["USER", "CHANNEL", "GUILD_MEMBER", "MESSAGE", "REACTION"],
restGlobalRateLimit: 20,
restTimeOffset: 1000,
restGlobalRateLimit: 50,
// restTimeOffset: 1000,
// Disable mentions by default
allowedMentions: {