aboutsummaryrefslogtreecommitdiff
path: root/src/lib/extensions/BushClient.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/extensions/BushClient.ts')
-rw-r--r--src/lib/extensions/BushClient.ts14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/lib/extensions/BushClient.ts b/src/lib/extensions/BushClient.ts
index 8592281..ad22cfe 100644
--- a/src/lib/extensions/BushClient.ts
+++ b/src/lib/extensions/BushClient.ts
@@ -9,6 +9,7 @@ import * as config from '../../config/options';
import * as Models from '../models';
import AllowedMentions from '../utils/AllowedMentions';
import { BushCache } from '../utils/BushCache';
+import { BushConstants } from '../utils/BushConstants';
import { BushLogger } from '../utils/BushLogger';
import { BushClientUtil } from './BushClientUtil';
import { BushCommandHandler } from './BushCommandHandler';
@@ -34,6 +35,7 @@ export class BushClient extends AkairoClient {
public declare ownerID: Snowflake[];
public db: Sequelize;
public logger: BushLogger;
+ public constants = BushConstants;
constructor(config: BotConfig) {
super(
{
@@ -107,7 +109,7 @@ export class BushClient extends AkairoClient {
dialect: 'postgres',
host: this.config.db.host,
port: this.config.db.port,
- logging: false
+ logging: (a, b) => this.logger.debug(a)
});
this.logger = new BushLogger(this);
}
@@ -116,6 +118,10 @@ export class BushClient extends AkairoClient {
return this.logger;
}
+ get consts(): typeof BushConstants {
+ return this.constants;
+ }
+
// Initialize everything
private async _init(): Promise<void> {
this.commandHandler.useListenerHandler(this.listenerHandler);
@@ -152,17 +158,20 @@ export class BushClient extends AkairoClient {
public async dbPreInit(): Promise<void> {
try {
await this.db.authenticate();
+ Models.Global.initModel(this.db);
Models.Guild.initModel(this.db, this);
Models.Modlog.initModel(this.db);
Models.Ban.initModel(this.db);
Models.Level.initModel(this.db);
+ Models.StickyRole.initModel(this.db);
await this.db.sync(); // Sync all tables to fix everything if updated
this.console.success('Startup', `Successfully connected to <<database>>.`, false);
} catch (error) {
- this.console.error('Startup', `Failed to connect to <<database>> with error:\n` + error, false);
+ this.console.error('Startup', `Failed to connect to <<database>> with error:\n` + error?.stack, false);
}
}
+ /** Starts the bot */
public async start(): Promise<void> {
try {
await this._init();
@@ -173,6 +182,7 @@ export class BushClient extends AkairoClient {
}
}
+ /** Logs out, terminates the connection to Discord, and destroys the client. */
public destroy(relogin = false): void | Promise<string> {
super.destroy();
if (relogin) {