From 7635ccdbda1bbf14dd0cca52cd0e8e00e1194d62 Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Thu, 9 Sep 2021 21:51:12 -0400 Subject: make db password redacted --- src/lib/extensions/discord-akairo/BushClient.ts | 11 +++-- .../extensions/discord-akairo/BushClientUtil.ts | 52 +++++++++++++++++----- 2 files changed, 45 insertions(+), 18 deletions(-) (limited to 'src/lib/extensions/discord-akairo') diff --git a/src/lib/extensions/discord-akairo/BushClient.ts b/src/lib/extensions/discord-akairo/BushClient.ts index 7d84b5e..4c877f3 100644 --- a/src/lib/extensions/discord-akairo/BushClient.ts +++ b/src/lib/extensions/discord-akairo/BushClient.ts @@ -1,4 +1,3 @@ -import chalk from 'chalk'; import { AkairoClient, ContextMenuCommandHandler } from 'discord-akairo'; import { Awaited, @@ -21,7 +20,6 @@ import eventsIntercept from 'events-intercept'; import JSON5 from 'json5'; import 'json5/lib/register'; import path from 'path'; -import { exit } from 'process'; import readline from 'readline'; import { Sequelize } from 'sequelize'; import { abbreviatedNumberTypeCaster } from '../../../arguments/abbreviatedNumber'; @@ -292,7 +290,8 @@ export class BushClient extends AkairoClient this.logger.debug(sql) : false + logging: this.config.logging.db ? (sql) => this.logger.debug(sql) : false, + timezone: 'America/New_York' }); } @@ -367,9 +366,10 @@ export class BushClient extends AkairoClient> with error:\n${typeof e}` === 'object' ? e?.stack : e, + `Failed to connect to <> with error:\n${util.inspect(e, { colors: true, depth: 1 })}`, false ); + process.exit(2); } } @@ -397,8 +397,7 @@ export class BushClient extends AkairoClient { - const expires = options.duration ? new Date(new Date().getTime() + options.duration ?? 0) : undefined; + const expires = options.duration ? new Date(+new Date() + options.duration ?? 0) : undefined; const user = (await util.resolveNonCachedUser(options.user))!.id; const guild = client.guilds.resolveId(options.guild)!; const type = this.#findTypeEnum(options.type)!; - const entry = options.extraInfo - ? ActivePunishment.build({ user, type, guild, expires, modlog: options.modlog, extraInfo: options.extraInfo }) - : ActivePunishment.build({ user, type, guild, expires, modlog: options.modlog }); + console.debug(expires); + + const entry = ActivePunishment.build( + options.extraInfo + ? { user, type, guild, expires, modlog: options.modlog, extraInfo: options.extraInfo } + : { user, type, guild, expires, modlog: options.modlog } + ); return await entry.save().catch(async (e) => { await util.handleError('createPunishmentEntry', e); return null; @@ -1200,6 +1207,7 @@ export class BushClientUtil extends ClientUtil { type: 'mute' | 'ban' | 'role' | 'block'; user: BushGuildMemberResolvable; guild: BushGuildResolvable; + extraInfo?: Snowflake; }): Promise { const user = await util.resolveNonCachedUser(options.user); const guild = client.guilds.resolveId(options.guild); @@ -1211,7 +1219,9 @@ export class BushClientUtil extends ClientUtil { const entries = await ActivePunishment.findAll({ // finding all cases of a certain type incase there were duplicates or something - where: { user: user.id, guild: guild, type } + where: options.extraInfo + ? { user: user.id, guild: guild, type, extraInfo: options.extraInfo } + : { user: user.id, guild: guild, type } }).catch(async (e) => { await util.handleError('removePunishmentEntry', e); success = false; @@ -1243,6 +1253,24 @@ export class BushClientUtil extends ClientUtil { else return humanizeDuration(duration, { language: 'en', maxDecimalPoints: 2 }); } + public timestampDuration(duration: number): string { + return ``; + } + + /** + * **Styles:** + * - **t**: Short Time + * - **T**: Long Time + * - **d**: Short Date + * - **D**: Long Date + * - **f**: Short Date/Time + * - **F**: Long Date/Time + * - **R**: Relative Time + */ + public timestamp(date: Date, style: 't' | 'T' | 'd' | 'D' | 'f' | 'F' | 'R' = 'f'): string { + return ``; + } + public dateDelta(date: Date, largest?: number) { return this.humanizeDuration(moment(date).diff(moment()), largest ?? 3); } -- cgit