diff options
Diffstat (limited to 'src/lib/extensions')
-rw-r--r-- | src/lib/extensions/discord-akairo/BushClient.ts | 7 | ||||
-rw-r--r-- | src/lib/extensions/global.d.ts | 4 |
2 files changed, 10 insertions, 1 deletions
diff --git a/src/lib/extensions/discord-akairo/BushClient.ts b/src/lib/extensions/discord-akairo/BushClient.ts index 8de630f..5b9ac1b 100644 --- a/src/lib/extensions/discord-akairo/BushClient.ts +++ b/src/lib/extensions/discord-akairo/BushClient.ts @@ -15,7 +15,9 @@ import { Structures, WebhookEditMessageOptions } from 'discord.js'; -import * as path from 'path'; +import JSON5 from 'json5'; +import 'json5/lib/register'; +import path from 'path'; import { exit } from 'process'; import readline from 'readline'; import { Sequelize } from 'sequelize'; @@ -100,6 +102,8 @@ type If<T extends boolean, A, B = null> = T extends true ? A : T extends false ? export class BushClient<Ready extends boolean = boolean> extends AkairoClient<Ready> { public static preStart(): void { + global.JSON5 = JSON5; + Structures.extend('GuildEmoji', () => BushGuildEmoji); Structures.extend('DMChannel', () => BushDMChannel); Structures.extend('TextChannel', () => BushTextChannel); @@ -180,6 +184,7 @@ export class BushClient<Ready extends boolean = boolean> extends AkairoClient<Re directory: path.join(__dirname, '..', '..', '..', 'commands'), prefix: async ({ guild }: { guild: Guild }) => { if (this.config.isDevelopment) return 'dev '; + if (!guild) return this.config.prefix; const row = await GuildModel.findByPk(guild.id); return (row?.prefix ?? this.config.prefix) as string; }, diff --git a/src/lib/extensions/global.d.ts b/src/lib/extensions/global.d.ts index d4c5f61..10869d0 100644 --- a/src/lib/extensions/global.d.ts +++ b/src/lib/extensions/global.d.ts @@ -1,12 +1,16 @@ +import { parse, stringify } from 'json5'; import { BushClient } from './discord-akairo/BushClient'; import { BushClientUtil } from './discord-akairo/BushClientUtil'; declare global { + type JSON5 = { parse: typeof parse; stringify: typeof stringify }; namespace NodeJS { export interface Global { client: BushClient; util: BushClientUtil; + JSON5: JSON5; } } const client: BushClient; const util: BushClientUtil; + const JSON5: JSON5; } |