feat(types): type AnyContext

This commit is contained in:
Marcos Susaña 2024-09-06 21:50:03 -04:00
parent 00d7f75610
commit 3cb52086cb
No known key found for this signature in database
2 changed files with 12 additions and 12 deletions

3
src/cache/index.ts vendored
View File

@ -33,6 +33,9 @@ import {
import type { InternalOptions, UsingClient } from '../commands';
import { Overwrites } from './resources/overwrites';
import { Messages } from './resources/messages';
export { BaseResource } from './resources/default/base';
export { GuildRelatedResource } from './resources/default/guild-related';
export { GuildBasedResource } from './resources/default/guild-based';
export type InferAsyncCache = InternalOptions extends { asyncCache: infer P } ? P : false;
export type ReturnCache<T> = If<InferAsyncCache, Promise<T>, T>;

View File

@ -1,6 +1,7 @@
import { ApplicationCommandOptionType, type APIApplicationCommandOptionChoice, type ChannelType } from '../../types';
import type {
AutocompleteCallback,
EntryPointContext,
MenuCommandContext,
OnAutocompleteErrorCallback,
ReturnOptionsTypes,
@ -82,17 +83,13 @@ export function createAttachmentOption<T extends SeyfertAttachmentOption = Seyfe
return { ...data, type: ApplicationCommandOptionType.Attachment } as const;
}
export function createMiddleware<
T = any,
C extends
| CommandContext
| MenuCommandContext<MessageCommandInteraction<boolean> | UserCommandInteraction<boolean>>
| ComponentContext
| ModalContext =
| CommandContext
| MenuCommandContext<MessageCommandInteraction<boolean> | UserCommandInteraction<boolean>>
| ComponentContext
| ModalContext,
>(data: MiddlewareContext<T, C>) {
export type AnyContext =
| CommandContext
| MenuCommandContext<MessageCommandInteraction<boolean> | UserCommandInteraction<boolean>>
| ComponentContext
| ModalContext
| EntryPointContext;
export function createMiddleware<T = any, C extends AnyContext = AnyContext>(data: MiddlewareContext<T, C>) {
return data;
}