From dcdfc1fda7cfedf7c0f69ba51857fd7ebc71a2dd Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Wed, 29 Dec 2021 16:20:06 -0500 Subject: refactoring & documentation --- src/lib/extensions/discord-akairo/BushClient.ts | 49 ++---------------------- src/lib/extensions/discord-akairo/BushCommand.ts | 13 ++++++- 2 files changed, 15 insertions(+), 47 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 7321c17..706b52a 100644 --- a/src/lib/extensions/discord-akairo/BushClient.ts +++ b/src/lib/extensions/discord-akairo/BushClient.ts @@ -11,33 +11,30 @@ import { snowflake } from '#args'; import type { - BushApplicationCommand, BushBaseGuildEmojiManager, BushChannelManager, BushClientEvents, BushClientUser, BushGuildManager, - BushReactionEmoji, - BushStageChannel, BushUserManager, + BushUserResolvable, Config } from '#lib'; -import { patch, PatchedElements } from '@notenoughupdates/events-intercept'; +import { patch, type PatchedElements } from '@notenoughupdates/events-intercept'; import * as Sentry from '@sentry/node'; import { AkairoClient, ContextMenuCommandHandler, version as akairoVersion } from 'discord-akairo'; import { - Awaitable, Intents, Options, Structures, version as discordJsVersion, - type Collection, + type Awaitable, + type If, type InteractionReplyOptions, type Message, type MessageEditOptions, type MessageOptions, type MessagePayload, - type PartialDMChannel, type ReplyMessageOptions, type Snowflake, type WebhookEditMessageOptions @@ -93,42 +90,6 @@ export type BushEditMessageType = string | MessageEditOptions | MessagePayload; export type BushSlashSendMessageType = string | MessagePayload | InteractionReplyOptions; export type BushSlashEditMessageType = string | MessagePayload | WebhookEditMessageOptions; export type BushSendMessageType = string | MessagePayload | MessageOptions; -export type BushThreadMemberResolvable = BushThreadMember | BushUserResolvable; -export type BushUserResolvable = BushUser | Snowflake | BushMessage | BushGuildMember | BushThreadMember; -export type BushGuildMemberResolvable = BushGuildMember | BushUserResolvable; -export type BushRoleResolvable = BushRole | Snowflake; -export type BushMessageResolvable = Message | BushMessage | Snowflake; -export type BushEmojiResolvable = Snowflake | BushGuildEmoji | BushReactionEmoji; -export type BushEmojiIdentifierResolvable = string | BushEmojiResolvable; -export type BushThreadChannelResolvable = BushThreadChannel | Snowflake; -export type BushApplicationCommandResolvable = BushApplicationCommand | Snowflake; -export type BushGuildTextChannelResolvable = BushTextChannel | BushNewsChannel | Snowflake; -export type BushChannelResolvable = BushAnyChannel | Snowflake; -export type BushGuildChannelResolvable = Snowflake | BushGuildBasedChannel; -export type BushAnyChannel = - | BushCategoryChannel - | BushDMChannel - | PartialDMChannel - | BushNewsChannel - | BushStageChannel - // eslint-disable-next-line deprecation/deprecation - | BushStoreChannel - | BushTextChannel - | BushThreadChannel - | BushVoiceChannel; -export type BushTextBasedChannel = PartialDMChannel | BushThreadChannel | BushDMChannel | BushNewsChannel | BushTextChannel; -export type BushTextBasedChannelTypes = BushTextBasedChannel['type']; -export type BushVoiceBasedChannel = Extract; -export type BushGuildBasedChannel = Extract; -export type BushNonThreadGuildBasedChannel = Exclude; -export type BushGuildTextBasedChannel = Extract; -export type BushTextChannelResolvable = Snowflake | BushTextChannel; -export type BushGuildVoiceChannelResolvable = BushVoiceBasedChannel | Snowflake; - -export interface BushFetchedThreads { - threads: Collection; - hasMore?: boolean; -} const rl = readline.createInterface({ input: process.stdin, @@ -136,8 +97,6 @@ const rl = readline.createInterface({ terminal: false }); -type If = T extends true ? A : T extends false ? B : A | B; - const __dirname = path.dirname(fileURLToPath(import.meta.url)); /** diff --git a/src/lib/extensions/discord-akairo/BushCommand.ts b/src/lib/extensions/discord-akairo/BushCommand.ts index 0d0a0a8..c37a55f 100644 --- a/src/lib/extensions/discord-akairo/BushCommand.ts +++ b/src/lib/extensions/discord-akairo/BushCommand.ts @@ -511,6 +511,11 @@ export interface BushCommand extends Command { * @param args - Evaluated arguments. */ exec(message: BushMessage, args: A): R; + /** + * Executes the command. + * @param message - Message that triggered the command. + * @param args - Evaluated arguments. + */ exec(message: BushMessage | BushSlashMessage, args: A): R; } @@ -523,5 +528,9 @@ type SlashOptionKeys = | keyof AkairoApplicationCommandNumericOptionData | keyof AkairoApplicationCommandSubCommandData; -export type ArgType = NonNullable; -export type OptionalArgType = BaseBushArgumentType[T]; +interface PseudoArguments extends BaseBushArgumentType { + boolean: boolean; +} + +export type ArgType = NonNullable; +export type OptionalArgType = PseudoArguments[T]; -- cgit