import { ApiHandler } from '../api'; import type { Adapter, DisabledCache } from '../cache'; import { Cache } from '../cache'; import type { Command, CommandContext, ContextMenuCommand, ExtendContext, ExtendedRC, ExtendedRCLocations, ExtraProps, MenuCommandContext, ResolvedRegisteredMiddlewares, UsingClient } from '../commands'; import { SubCommand } from '../commands'; import { type AnyMiddlewareContext, type InferWithPrefix, type MiddlewareContext } from '../commands/applications/shared'; import type { BaseContext } from '../commands/basecontext'; import { HandleCommand } from '../commands/handle'; import { CommandHandler } from '../commands/handler'; import { ApplicationShorter, ChannelShorter, EmojiShorter, GuildShorter, InteractionShorter, InvitesShorter, Logger, type LoggerOptions, type MakeRequired, MemberShorter, MessageShorter, ReactionShorter, RoleShorter, TemplateShorter, ThreadShorter, UsersShorter, WebhookShorter } from '../common'; import { BanShorter } from '../common/shorters/bans'; import { SoundboardShorter } from '../common/shorters/soundboard'; import { VoiceStateShorter } from '../common/shorters/voiceStates'; import type { Awaitable, DeepPartial, OmitInsert, PermissionStrings, When } from '../common/types/util'; import { ComponentCommand, ModalCommand } from '../components'; import { ComponentHandler } from '../components/handler'; import { type CustomEventRunner } from '../events'; import { LangsHandler } from '../langs/handler'; import type { ChatInputCommandInteraction, ComponentInteraction, EntryPointInteraction, MessageCommandInteraction, ModalSubmitInteraction, UserCommandInteraction } from '../structures'; import { type APIInteraction, type APIInteractionResponse, type LocaleString, type RESTPostAPIChannelMessageJSONBody } from '../types'; import { type GatewayIntentInput } from './intents'; import { type AnySeyfertPlugin, type PluginMiddlewareDenialMetadata, type PluginSharedRegistry, type ResolvedPluginList } from './plugins'; import type { MessageStructure } from './transformers'; export type ContextScopeContext = BaseContext & ExtendContext; export type ContextScope = (context: ContextScopeContext, run: () => Awaitable) => Awaitable; type ResolvedMiddlewareKey> = Extract; export type ClientMiddlewares = ResolvedRegisteredMiddlewares> = [ ResolvedMiddlewareKey ] extends [never] ? Record : { [K in ResolvedMiddlewareKey]?: T[K]; }; export declare class BaseClient { rest: ApiHandler; cache: Cache; applications: ApplicationShorter; users: UsersShorter; channels: ChannelShorter; guilds: GuildShorter; messages: MessageShorter; members: MemberShorter; webhooks: WebhookShorter; templates: TemplateShorter; roles: RoleShorter; reactions: ReactionShorter; emojis: EmojiShorter; threads: ThreadShorter; bans: BanShorter; interactions: InteractionShorter; voiceStates: VoiceStateShorter; soundboards: SoundboardShorter; invites: InvitesShorter; debugger?: Logger; logger: Logger; langs: LangsHandler; commands: CommandHandler; components: ComponentHandler; handleCommand: HandleCommand; private _applicationId?; private _botId?; middlewares?: ClientMiddlewares; protected static getBotIdFromToken(token: string): string; readonly plugins: ResolvedPluginList; shared: PluginSharedRegistry; events: CustomEventRunner; private pluginsSetupPromise?; private pluginsClosePromise?; private langBaseValues; private pluginCacheDisabledCache; private pluginBaseGatewayIntents; private pluginComponentsBeforeLoadDepth; options: BaseClientOptions; constructor(options?: BaseClientOptions); protected configureLogger(defaults: LoggerOptions, options?: LoggerOptions): void; get proxy(): import("..").APIRoutes; set botId(id: string); get botId(): string; set applicationId(id: string); get applicationId(): string; setServices({ rest, cache, langs, middlewares, handleCommand }: ServicesOptions): void; protected execute(..._options: unknown[]): Promise; start(options?: Pick, 'langsDir' | 'commandsDir' | 'connection' | 'token' | 'componentsDir'>): Promise; reloadPluginContributions(): Promise; private bindPluginRestObserverProvider; private bindPluginLangReload; private refreshPluginCacheResources; protected resolvePluginGatewayIntents(base?: GatewayIntentInput): number; private reloadPluginMiddlewares; private reloadPluginCommands; private reloadPluginComponents; private setupPlugins; /** * Closes resources managed by the plugin lifecycle. * * This waits for in-flight plugin setup and runs `SeyfertPlugin.teardown`. * It does not close the gateway, REST client, or cache adapter. */ close(): Promise; private applyPluginCommands; private get loadedCommands(); private applyPluginComponents; private createPluginCommandInstance; private createPluginComponentInstance; private runPluginHandlerCreators; private matchesPluginHandlerKind; private createPluginLoadedMetadata; private emitPluginCustomEvent; protected onPacket(..._packet: unknown[]): Promise; /** * * @param rawBody body of interaction * @returns */ onInteractionRequest(rawBody: APIInteraction): Promise<{ headers: { 'Content-Type'?: string; }; response: APIInteractionResponse | FormData; }>; private shouldUploadCommands; private syncCachePath; private cachedCommandGuilds; uploadCommands({ applicationId, cachePath }?: { applicationId?: string; cachePath?: string; }): Promise; private emitUploadCommandsMetadata; loadCommands(dir?: string): Promise; loadComponents(dir?: string): Promise; loadLangs(dir?: string): Promise; private applyPluginLangs; t(locale: string): import("..").SeyfertLocale; getRC(): Promise; } export interface BaseClientOptions { plugins?: readonly AnySeyfertPlugin[]; contextScopes?: readonly ContextScope[]; context?: (interaction: ChatInputCommandInteraction | UserCommandInteraction | MessageCommandInteraction | ComponentInteraction | ModalSubmitInteraction | EntryPointInteraction | When) => Record; globalMiddlewares?: readonly (keyof ResolvedRegisteredMiddlewares)[]; commands?: { defaults?: { onBeforeMiddlewares?: (context: CommandContext | MenuCommandContext) => unknown; onBeforeOptions?: Command['onBeforeOptions']; onRunError?: (context: MenuCommandContext | CommandContext, error: unknown) => unknown; onPermissionsFail?: Command['onPermissionsFail']; onBotPermissionsFail?: (context: MenuCommandContext | CommandContext, permissions: PermissionStrings) => unknown; onInternalError?: (client: UsingClient, command: Command | SubCommand | ContextMenuCommand, error?: unknown) => unknown; onMiddlewaresError?: (context: CommandContext | MenuCommandContext, error: string, metadata: PluginMiddlewareDenialMetadata) => unknown; onOptionsError?: Command['onOptionsError']; onAfterRun?: (context: CommandContext | MenuCommandContext, error: unknown) => unknown; props?: ExtraProps; }; }; components?: { defaults?: { onBeforeMiddlewares?: ComponentCommand['onBeforeMiddlewares']; onRunError?: ComponentCommand['onRunError']; onInternalError?: ComponentCommand['onInternalError']; onMiddlewaresError?: ComponentCommand['onMiddlewaresError']; onAfterRun?: ComponentCommand['onAfterRun']; }; }; modals?: { defaults?: { onBeforeMiddlewares?: ModalCommand['onBeforeMiddlewares']; onRunError?: ModalCommand['onRunError']; onInternalError?: ModalCommand['onInternalError']; onMiddlewaresError?: ModalCommand['onMiddlewaresError']; onAfterRun?: ModalCommand['onAfterRun']; }; }; allowedMentions?: RESTPostAPIChannelMessageJSONBody['allowed_mentions']; logger?: LoggerOptions; getRC?(): Awaitable; } export interface StartOptions { eventsDir: string; langsDir: string; commandsDir: string; componentsDir: string; connection: { intents: GatewayIntentInput; }; httpConnection: { publicKey: string; port: number; }; token: string; } interface RCLocations extends ExtendedRCLocations { base: string; commands?: string; langs?: string; events?: string; components?: string; } interface RC extends ExtendedRC { debug?: boolean; locations: RCLocations; token: string; intents?: number; applicationId?: string; port?: number; publicKey?: string; } export type ResolvedRC = Readonly & { locations: Readonly>; debug: boolean; intents: number; }>; export type InternalRuntimeConfigHTTP = Omit, 'intents' | 'locations'> & { locations: Omit; }; export type RuntimeConfigHTTP = Omit, 'intents' | 'locations'> & { locations: Omit; }; export type InternalRuntimeConfig = MakeRequired; export type RuntimeConfig = OmitInsert; export type BotConfig = InternalRuntimeConfig; export type HttpConfig = InternalRuntimeConfigHTTP; export interface ServicesOptions { rest?: ApiHandler; cache?: { adapter?: Adapter; disabledCache?: boolean | DisabledCache | ((cacheType: keyof DisabledCache) => boolean); }; langs?: { default?: string; preferGuildLocale?: boolean; aliases?: Record; }; middlewares?: ClientMiddlewares; /** * Custom command handler subclass constructor. Pass the class itself, not an instance. */ handleCommand?: new (client: UsingClient) => HandleCommand; } export {};