2 |
import { format } from "date-fns"; |
import { format } from "date-fns"; |
3 |
import { appendFile } from "fs/promises"; |
import { appendFile } from "fs/promises"; |
4 |
import path from "path"; |
import path from "path"; |
|
import { exit } from "process"; |
|
5 |
import DiscordClient from "../../client/Client"; |
import DiscordClient from "../../client/Client"; |
6 |
import { LogLevel } from "../../services/DebugLogger"; |
import { LogLevel } from "../../services/DebugLogger"; |
7 |
import BaseEvent from "../../utils/structures/BaseEvent"; |
import BaseEvent from "../../utils/structures/BaseEvent"; |
23 |
console.log("DEBUG: ", e); |
console.log("DEBUG: ", e); |
24 |
await appendFile(this.logFile, `[${format(new Date(), "yyyy-MM-dd'T'HH:mm:ss.SSSxxx")}] [LOG] ${e}\n`); |
await appendFile(this.logFile, `[${format(new Date(), "yyyy-MM-dd'T'HH:mm:ss.SSSxxx")}] [LOG] ${e}\n`); |
25 |
|
|
26 |
if (process.env.PLATFORM === 'replit' && e.includes("Hit a 429 while executing a request") && !client.isReady()) { |
if (process.env.PLATFORM === 'replit' && e.includes("Hit a 429") && !client.isReady()) { |
27 |
console.log("DEBUG: ", "Restart Required"); |
console.log("DEBUG: ", "Restart Required"); |
28 |
await appendFile(this.logFile, `[${format(new Date(), "yyyy-MM-dd'T'HH:mm:ss.SSSxxx")}] [LOG] ${e}\n`); |
await appendFile(this.logFile, `[${format(new Date(), "yyyy-MM-dd'T'HH:mm:ss.SSSxxx")}] [LOG] ${e}\n`); |
29 |
await appendFile(this.logFile, `[${format(new Date(), "yyyy-MM-dd'T'HH:mm:ss.SSSxxx")}] [FATAL] Restart Required\n`); |
await appendFile(this.logFile, `[${format(new Date(), "yyyy-MM-dd'T'HH:mm:ss.SSSxxx")}] [FATAL] Restart Required\n`); |
30 |
await client.debugLogger.logToHomeServer("Discord Ratelimit [419]: System restart required.\nAutomated restart is in progress.", LogLevel.WARN); |
await client.debugLogger.logToHomeServer("Discord Ratelimit [429]: System restart required.\nAutomated restart is in progress.", LogLevel.WARN); |
31 |
|
|
32 |
exec("kill 1"); |
exec("kill 1"); |
33 |
return; |
return; |