diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-07-17 14:11:37 -0400 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-07-17 14:11:37 -0400 |
commit | da70ed6f4ad82c58adf7dc6120aa8b6b255238e9 (patch) | |
tree | a1d80d6d89ae249893c300234d034934a55ea0b4 /src/lib/utils | |
parent | d1724227abfb8f0fcd9e573f7e9772cf0be8257a (diff) | |
download | tanzanite-da70ed6f4ad82c58adf7dc6120aa8b6b255238e9.tar.gz tanzanite-da70ed6f4ad82c58adf7dc6120aa8b6b255238e9.tar.bz2 tanzanite-da70ed6f4ad82c58adf7dc6120aa8b6b255238e9.zip |
rewrote config for absolutly no reason :troll:
Diffstat (limited to 'src/lib/utils')
-rw-r--r-- | src/lib/utils/BushLogger.ts | 4 | ||||
-rw-r--r-- | src/lib/utils/Config.ts | 49 |
2 files changed, 51 insertions, 2 deletions
diff --git a/src/lib/utils/BushLogger.ts b/src/lib/utils/BushLogger.ts index 915d8f1..98c3c04 100644 --- a/src/lib/utils/BushLogger.ts +++ b/src/lib/utils/BushLogger.ts @@ -86,7 +86,7 @@ export class BushLogger { * @param depth - The depth the content will inspected. Defaults to 0. */ public debug(content: any, depth = 0): void { - if (!this.client.config.dev) return; + if (!this.client.config.isDevelopment) return; const newContent = this.inspectContent(content, depth, true); console.log(`${chalk.bgMagenta(this.getTimeStamp())} ${chalk.magenta('[Debug]')}`, newContent); } @@ -96,7 +96,7 @@ export class BushLogger { * @param content - The content to log. */ public debugRaw(...content: any): void { - if (!this.client.config.dev) return; + if (!this.client.config.isDevelopment) return; console.log(`${chalk.bgMagenta(this.getTimeStamp())} ${chalk.magenta('[Debug]')}`, ...content); } diff --git a/src/lib/utils/Config.ts b/src/lib/utils/Config.ts new file mode 100644 index 0000000..d6b5802 --- /dev/null +++ b/src/lib/utils/Config.ts @@ -0,0 +1,49 @@ +import { Snowflake } from 'discord.js'; + +export interface ConfigOptions { + credentials: { token: string; betaToken: string; devToken: string; hypixelApiKey: string }; + environment: 'production' | 'beta' | 'development'; + owners: Snowflake[]; + prefix: string; + channels: { log: Snowflake; error: Snowflake; dm: Snowflake }; + db: { host: string; port: number; username: string; password: string }; + logging: { db: boolean; verbose: boolean; info: boolean }; +} + +export class Config { + public credentials: { token: string; betaToken: string; devToken: string; hypixelApiKey: string }; + public environment: 'production' | 'beta' | 'development'; + public owners: Snowflake[]; + public prefix: string; + public channels: { log: Snowflake; error: Snowflake; dm: Snowflake }; + public db: { host: string; port: number; username: string; password: string }; + public logging: { db: boolean; verbose: boolean; info: boolean }; + + public constructor(options: ConfigOptions) { + this.credentials = options.credentials; + this.environment = options.environment; + this.owners = options.owners; + this.prefix = options.prefix; + this.channels = options.channels; + this.db = options.db; + this.logging = options.logging; + } + + public get token(): string { + return this.environment === 'production' + ? this.credentials.token + : this.environment === 'beta' + ? this.credentials.betaToken + : this.credentials.devToken; + } + + public get isProduction(): boolean { + return this.environment === 'production'; + } + public get isBeta(): boolean { + return this.environment === 'beta'; + } + public get isDevelopment(): boolean { + return this.environment === 'development'; + } +} |