seyfert
Version:
The most advanced framework for discord bots
52 lines (51 loc) • 4.38 kB
TypeScript
import type { ReturnCache } from '../..';
import type { GuildMemberStructure, GuildStructure, InteractionGuildMemberStructure, MessageStructure, OptionResolverStructure, UserStructure, WebhookMessageStructure } from '../../client/transformers';
import type { If, MakeRequired, UnionToTuple, When } from '../../common';
import type { InteractionCreateBodyRequest, InteractionMessageUpdateBodyRequest } from '../../common/types/write';
import { type AllChannels, ChatInputCommandInteraction } from '../../structures';
import { BaseContext } from '../basecontext';
import type { RegisteredMiddlewares } from '../decorators';
import type { Command, ContextOptions, OptionsRecord, SubCommand } from './chat';
import type { CommandMetadata, ExtendContext, GlobalMetadata, InferWithPrefix, UsingClient } from './shared';
export interface CommandContext<T extends OptionsRecord = {}, M extends keyof RegisteredMiddlewares = never> extends BaseContext, ExtendContext {
}
export declare class CommandContext<T extends OptionsRecord = {}, M extends keyof RegisteredMiddlewares = never> extends BaseContext {
readonly client: UsingClient;
readonly resolver: OptionResolverStructure;
readonly shardId: number;
readonly command: Command | SubCommand;
message: If<InferWithPrefix, MessageStructure | undefined, undefined>;
interaction: If<InferWithPrefix, ChatInputCommandInteraction | undefined, ChatInputCommandInteraction>;
messageResponse?: If<InferWithPrefix, MessageStructure | undefined>;
constructor(client: UsingClient, data: ChatInputCommandInteraction | MessageStructure, resolver: OptionResolverStructure, shardId: number, command: Command | SubCommand);
options: ContextOptions<T>;
metadata: CommandMetadata<UnionToTuple<M>>;
globalMetadata: GlobalMetadata;
get proxy(): import("../..").APIRoutes;
get t(): import("../..").__InternalParseLocale<import("./shared").DefaultLocale> & {
get(locale?: string): import("./shared").DefaultLocale;
};
get fullCommandName(): string;
write<WR extends boolean = false>(body: InteractionCreateBodyRequest, withResponse?: WR): Promise<When<WR, WebhookMessageStructure | When<InferWithPrefix, MessageStructure, never>, void | WebhookMessageStructure | When<InferWithPrefix, MessageStructure, never>>>;
deferReply<WR extends boolean = false>(ephemeral?: boolean, withResponse?: WR): Promise<When<WR, WebhookMessageStructure | When<InferWithPrefix, MessageStructure, never>, When<InferWithPrefix, MessageStructure, never> | undefined>>;
editResponse(body: InteractionMessageUpdateBodyRequest): Promise<When<InferWithPrefix, WebhookMessageStructure | MessageStructure, WebhookMessageStructure>>;
deleteResponse(): Promise<void>;
editOrReply<WR extends boolean = false>(body: InteractionCreateBodyRequest | InteractionMessageUpdateBodyRequest, withResponse?: WR): Promise<When<WR, WebhookMessageStructure | When<InferWithPrefix, MessageStructure, never>, void | WebhookMessageStructure | When<InferWithPrefix, MessageStructure, never>>>;
fetchResponse(): Promise<If<InferWithPrefix, WebhookMessageStructure | MessageStructure, WebhookMessageStructure>>;
channel(mode?: 'rest' | 'flow'): Promise<If<InferWithPrefix, AllChannels | undefined, AllChannels>>;
channel(mode: 'cache'): ReturnCache<If<InferWithPrefix, AllChannels | undefined, AllChannels>>;
me(mode?: 'rest' | 'flow'): Promise<GuildMemberStructure>;
me(mode: 'cache'): ReturnCache<GuildMemberStructure | undefined>;
guild(mode?: 'rest' | 'flow'): Promise<GuildStructure<'cached' | 'api'> | undefined>;
guild(mode: 'cache'): ReturnCache<GuildStructure<'cached'> | undefined>;
get guildId(): string | undefined;
get channelId(): string;
get author(): UserStructure;
get member(): If<InferWithPrefix, GuildMemberStructure | InteractionGuildMemberStructure | undefined, InteractionGuildMemberStructure | undefined>;
isChat(): this is CommandContext<T, M>;
inGuild(): this is GuildCommandContext<T, M>;
}
export interface GuildCommandContext<T extends OptionsRecord = {}, M extends keyof RegisteredMiddlewares = never> extends Omit<MakeRequired<CommandContext<T, M>, 'guildId' | 'member'>, 'guild'> {
guild(mode?: 'rest' | 'flow'): Promise<GuildStructure<'cached' | 'api'>>;
guild(mode: 'cache'): ReturnCache<GuildStructure<'cached'> | undefined>;
}