1
0
mirror of https://github.com/toast-ts/Daggerbot-TS.git synced 2024-09-29 12:30:58 -04:00

Add debug logging

This commit is contained in:
toast-ts 2023-08-08 00:42:32 +10:00
parent 040503a9e5
commit 5126e066cb

View File

@ -1,5 +1,5 @@
import Discord, {Client, WebhookClient, GatewayIntentBits, Partials} from 'discord.js'; import Discord, {Client, WebhookClient, GatewayIntentBits, Partials} from 'discord.js';
import {readFileSync, readdirSync} from 'node:fs'; import {readFileSync, readdirSync, promises} from 'node:fs';
import {exec} from 'node:child_process'; import {exec} from 'node:child_process';
import mongoose from 'mongoose'; import mongoose from 'mongoose';
import {formatTimeOpt, Tokens, Config, repeatedMessages, MPServerCache} from './typings/interfaces'; import {formatTimeOpt, Tokens, Config, repeatedMessages, MPServerCache} from './typings/interfaces';
@ -105,10 +105,12 @@ export default class TClient extends Client {
}).then(()=>console.log(this.logTime(), 'Successfully connected to MongoDB')).catch(err=>{console.error(this.logTime(), `Failed to connect to MongoDB\n${err}`); exec('pm2 stop Daggerbot')}) }).then(()=>console.log(this.logTime(), 'Successfully connected to MongoDB')).catch(err=>{console.error(this.logTime(), `Failed to connect to MongoDB\n${err}`); exec('pm2 stop Daggerbot')})
this.login(this.tokens.main); this.login(this.tokens.main);
for await (const file of readdirSync('dist/events')){ for await (const file of readdirSync('dist/events')){
//console.log('EVENTS:', file)
const eventFile = await import(`./events/${file}`); const eventFile = await import(`./events/${file}`);
this.on(file.replace('.js',''), async(...args)=>eventFile.default.run(this,...args)) this.on(file.replace('.js',''), async(...args)=>eventFile.default.run(this,...args))
} }
for await (const file of readdirSync('dist/commands')){ for await (const file of readdirSync('dist/commands')){
//console.log('COMMANDS:', file)
const command = await import(`./commands/${file}`); const command = await import(`./commands/${file}`);
this.commands.set(command.default.data.name,{command, uses: 0}); this.commands.set(command.default.data.name,{command, uses: 0});
this.registry.push(command.default.data.toJSON()) this.registry.push(command.default.data.toJSON())