/[sudobot]/trunk/src/events/debug/DebugEvent.ts
ViewVC logotype

Annotation of /trunk/src/events/debug/DebugEvent.ts

Parent Directory Parent Directory | Revision Log Revision Log


Revision 292 - (hide annotations)
Mon Jul 29 17:29:23 2024 UTC (8 months, 2 weeks ago) by rakin
File MIME type: application/typescript
File size: 1201 byte(s)
perf: exec `kill 1` when login error occurs in replit
1 rakin 292 import { exec } from "child_process";
2 rakin 288 import { format } from "date-fns";
3     import { appendFile } from "fs/promises";
4     import path from "path";
5 rakin 292 import { exit } from "process";
6 rakin 288 import DiscordClient from "../../client/Client";
7 rakin 287 import BaseEvent from "../../utils/structures/BaseEvent";
8    
9     export default class DebugEvent extends BaseEvent {
10 rakin 288 logFile: string = path.resolve(__dirname, "..", "..", "..", "logs", 'debug.log');
11    
12 rakin 287 constructor() {
13     super("debug");
14 rakin 288 appendFile(this.logFile, `\n\n[${format(new Date(), "yyyy-MM-dd'T'HH:mm:ss.SSSxxx")}] [STARTUP] The system has started.\n`);
15 rakin 287 }
16    
17 rakin 288 async run(client: DiscordClient, e: string): Promise <void> {
18     if (e.includes("Provided token") || e.includes(process.env.TOKEN!) || e.includes("[READY] Session ")) {
19     console.log('DEBUG: [One hidden log]');
20     return;
21     }
22    
23 rakin 292 if (process.env.PLATFORM === 'replit' && e.includes("Hit a 429 while executing a request") && !client.isReady()) {
24     exec("kill 1");
25     return;
26     }
27    
28 rakin 288 console.log("DEBUG: ", e);
29     await appendFile(this.logFile, `[${format(new Date(), "yyyy-MM-dd'T'HH:mm:ss.SSSxxx")}] [LOG] ${e}\n`);
30 rakin 287 }
31     }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26