From 8fb88c737e49321ff2b612a9d0e0e059c64c272a Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Mon, 20 Dec 2021 22:50:45 -0500 Subject: do some fixes or something --- .../discord-akairo/BushArgumentTypeCaster.ts | 2 +- src/lib/extensions/discord-akairo/BushClient.ts | 9 ++-- .../extensions/discord-akairo/BushClientUtil.ts | 2 +- src/lib/extensions/discord-akairo/BushCommand.ts | 51 +++++++++++++--------- 4 files changed, 38 insertions(+), 26 deletions(-) (limited to 'src/lib/extensions/discord-akairo') diff --git a/src/lib/extensions/discord-akairo/BushArgumentTypeCaster.ts b/src/lib/extensions/discord-akairo/BushArgumentTypeCaster.ts index f27fb89..7a9a3db 100644 --- a/src/lib/extensions/discord-akairo/BushArgumentTypeCaster.ts +++ b/src/lib/extensions/discord-akairo/BushArgumentTypeCaster.ts @@ -1,3 +1,3 @@ import { type BushMessage } from '#lib'; -export type BushArgumentTypeCaster = (message: BushMessage, phrase: string) => any; +export type BushArgumentTypeCaster = (message: BushMessage, phrase: string) => R; diff --git a/src/lib/extensions/discord-akairo/BushClient.ts b/src/lib/extensions/discord-akairo/BushClient.ts index e5ce7be..a9e172a 100644 --- a/src/lib/extensions/discord-akairo/BushClient.ts +++ b/src/lib/extensions/discord-akairo/BushClient.ts @@ -187,8 +187,8 @@ export class BushClient extends AkairoClient { 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; + const prefix = await (guild as BushGuild).getSetting('prefix'); + return (prefix ?? this.config.prefix) as string; }, allowMention: true, handleEdits: true, @@ -348,7 +348,10 @@ export class BushClient extends AkairoClient>, not <<${process.version}>>.`, false)); + process.exit(2); + } this.intercept('ready', async (arg, done) => { await this.guilds.fetch(); const promises = this.guilds.cache.map((guild) => { diff --git a/src/lib/extensions/discord-akairo/BushClientUtil.ts b/src/lib/extensions/discord-akairo/BushClientUtil.ts index cded096..ab1f3ed 100644 --- a/src/lib/extensions/discord-akairo/BushClientUtil.ts +++ b/src/lib/extensions/discord-akairo/BushClientUtil.ts @@ -112,7 +112,7 @@ export class BushClientUtil extends ClientUtil { void this.handleError('haste', new Error(`content over 400,000 characters (${content.length.toLocaleString()})`)); return { error: 'content too long' }; } else if (content.length > 400_000) { - content = content.substr(0, 400_000); + content = content.substring(0, 400_000); isSubstr = true; } for (const url of this.#hasteURLs) { diff --git a/src/lib/extensions/discord-akairo/BushCommand.ts b/src/lib/extensions/discord-akairo/BushCommand.ts index d8f0d38..5111c19 100644 --- a/src/lib/extensions/discord-akairo/BushCommand.ts +++ b/src/lib/extensions/discord-akairo/BushCommand.ts @@ -1,4 +1,12 @@ -import { type BushClient, type BushCommandHandler, type BushMessage, type BushSlashMessage } from '#lib'; +import { + BushArgumentTypeCaster, + BushUser, + ParsedDuration, + type BushClient, + type BushCommandHandler, + type BushMessage, + type BushSlashMessage +} from '#lib'; import { AkairoApplicationCommandAutocompleteOption, AkairoApplicationCommandChannelOptionData, @@ -13,25 +21,26 @@ import { SlashOption, SlashResolveTypes, type ArgumentOptions, - type ArgumentTypeCaster, type CommandOptions } from 'discord-akairo'; -import { BaseArgumentType } from 'discord-akairo/dist/src/struct/commands/arguments/Argument'; -import { ApplicationCommandOptionChoice, type PermissionResolvable, type Snowflake } from 'discord.js'; - -export type BaseBushArgumentType = - | BaseArgumentType - | 'duration' - | 'contentWithDuration' - | 'permission' - | 'snowflake' - | 'discordEmoji' - | 'roleWithDuration' - | 'abbreviatedNumber' - | 'globalUser' - | 'messageLink'; - -export type BushArgumentType = BaseBushArgumentType | RegExp; +import { ArgumentType, ArgumentTypeCaster, BaseArgumentType } from 'discord-akairo/dist/src/struct/commands/arguments/Argument'; +import { ApplicationCommandOptionChoice, PermissionString, type PermissionResolvable, type Snowflake } from 'discord.js'; +import { DiscordEmojiInfo } from '../../../arguments/discordEmoji'; +import { RoleWithDuration } from '../../../arguments/roleWithDuration'; + +export interface BaseBushArgumentType extends BaseArgumentType { + duration: number | null; + contentWithDuration: ParsedDuration; + permission: PermissionString | null; + snowflake: Snowflake | null; + discordEmoji: DiscordEmojiInfo | null; + roleWithDuration: RoleWithDuration | null; + abbreviatedNumber: number | null; + globalUser: BushUser | null; + messageLink: BushMessage | null; +} + +export type BushArgumentType = keyof BaseBushArgumentType | RegExp; interface BaseBushArgumentOptions extends Omit { id: string; @@ -149,7 +158,7 @@ export interface BushArgumentOptions extends BaseBushArgumentOptions { * - `contentWithDuration` tries to parse duration in milliseconds and returns the remaining content with the duration * removed */ - type?: BushArgumentType | BaseBushArgumentType[]; + type?: BushArgumentType | (keyof BaseBushArgumentType)[] | BushArgumentTypeCaster; } export interface CustomBushArgumentOptions extends BaseBushArgumentOptions { /** @@ -160,7 +169,7 @@ export interface CustomBushArgumentOptions extends BaseBushArgumentOptions { * A regular expression can also be used. * The evaluated argument will be an object containing the `match` and `matches` if global. */ - customType?: ArgumentTypeCaster | (string | string[])[] | RegExp | string | null; + customType?: (string | string[])[] | RegExp | string | null; } export type BushMissingPermissionSupplier = (message: BushMessage | BushSlashMessage) => Promise | any; @@ -344,7 +353,7 @@ export class BushCommand extends Command { if ('retry' in arg) newArg.prompt.retry = arg.retry; if ('optional' in arg) newArg.prompt.optional = arg.optional; } - if ('type' in arg) newArg.type = arg.type; + if ('type' in arg) newArg.type = arg.type as ArgumentType | ArgumentTypeCaster; if ('unordered' in arg) newArg.unordered = arg.unordered; newTextArgs.push(newArg); } -- cgit