diff options
author | TymanWasTaken <tyman@tyman.tech> | 2021-05-16 20:30:34 -0400 |
---|---|---|
committer | TymanWasTaken <tyman@tyman.tech> | 2021-05-16 20:30:34 -0400 |
commit | 372718e567e060cead16dde5d6d190666b4dd575 (patch) | |
tree | 1fad29305b6277838833a7e8ae4381136212f301 /src/lib/extensions/BotClient.ts | |
parent | 1db014860c3cf6070bb29f75b6a8cf08070e5b9a (diff) | |
download | tanzanite-372718e567e060cead16dde5d6d190666b4dd575.tar.gz tanzanite-372718e567e060cead16dde5d6d190666b4dd575.tar.bz2 tanzanite-372718e567e060cead16dde5d6d190666b4dd575.zip |
add colored logging and improved logging code, fix a few moderation command issues, add more logging, and make ban check run every 30s not 60s
Diffstat (limited to 'src/lib/extensions/BotClient.ts')
-rw-r--r-- | src/lib/extensions/BotClient.ts | 40 |
1 files changed, 16 insertions, 24 deletions
diff --git a/src/lib/extensions/BotClient.ts b/src/lib/extensions/BotClient.ts index e2de812..99b40ef 100644 --- a/src/lib/extensions/BotClient.ts +++ b/src/lib/extensions/BotClient.ts @@ -15,27 +15,11 @@ import * as Tasks from '../../tasks'; import { v4 as uuidv4 } from 'uuid'; import { exit } from 'process'; import { Intents } from 'discord.js'; +import * as config from '../../config/options'; +import { Logger } from '../utils/Logger'; +import chalk from 'chalk'; -export interface BotConfig { - credentials: { - botToken: string; - }; - owners: string[]; - prefix: string; - dev: boolean; - db: { - username: string; - password: string; - host: string; - port: number; - }; - channels: { - log: string; - error: string; - dm: string; - command: string; - }; -} +export type BotConfig = typeof config; export class BotClient extends AkairoClient { public config: BotConfig; @@ -45,6 +29,7 @@ export class BotClient extends AkairoClient { public util: Util; public ownerID: string[]; public db: Sequelize; + public logger: Logger; constructor(config: BotConfig) { super( { @@ -114,6 +99,7 @@ export class BotClient extends AkairoClient { ); BotGuild.install(); BotMessage.install(); + this.logger = new Logger(this); } // Initialize everything @@ -134,14 +120,20 @@ export class BotClient extends AkairoClient { for (const loader of Object.keys(loaders)) { try { loaders[loader].loadAll(); - console.log('Successfully loaded ' + loader + '.'); + this.logger.log( + chalk.green('Successfully loaded ' + chalk.cyan(loader) + '.') + ); } catch (e) { - console.error('Unable to load loader ' + loader + ' with error ' + e); + console.error( + chalk.red( + 'Unable to load loader ' + chalk.cyan(loader) + ' with error ' + e + ) + ); } } await this.dbPreInit(); Object.keys(Tasks).forEach((t) => { - setInterval(() => Tasks[t](this), 60000); + setInterval(() => Tasks[t](this), 30000); }); } @@ -270,7 +262,7 @@ export class BotClient extends AkairoClient { await this._init(); await this.login(this.token); } catch (e) { - console.error(e.stack); + console.error(chalk.red(e.stack)); exit(2); } } |