WorkerClient
Signature
@Mixins(RegisteredPluginExtension)export declare class WorkerClient<Ready extends boolean = boolean> extends BaseClientProperties
76Methods
24Properties
memberUpdateHandler: MemberUpdateHandler;presenceUpdateHandler: PresenceUpdateHandler;collectors: Collectors;events: EventHandler;me: When<Ready, ClientUserStructure>;promises: Map<string, { resolve: (value: any) => void; timeout: NodeJS.Timeout;}>;shards: Map<number, Shard>;resharding: Map<number, Shard>;private dispatchState;Whether gateway events reach handlers. A hot reload replacement waits on standby, only building its cache, until the manager switches to it; the worker it replaces then stops and drains.
private hotReloadHookQueue;private standbyReadiness;The readiness handlers skipped on standby, in startup order, replayed when the replacement takes over.
private inFlightWork;Dispatched work a worker replaced by a hot reload waits for before it closes its sessions.
private pausedShard?;private cancelledSessionHandoff;private activateResumedShard?;private hotReloadRequests;options: WorkerClientOptions;workerIdGetterget workerId(): number;latencyGetterget latency(): number;private onShardDisconnect;private onShardReconnect;applicationIdGetterget applicationId(): When<Ready, string, ''>;applicationIdSetterset applicationId(id: string);workerDataGetterget workerData(): WorkerData;hotReloadStateGetterget hotReloadState(): 'active' | 'standby' | 'stopped';Where this worker stands in a hot reload: `'active'` handles gateway events, `'standby'` is a replacement still preparing next to the worker it replaces, and `'stopped'` was replaced and is draining. Outside a hot reload it is always `'active'`.
isHotReloadReplacementGetterget isHotReloadReplacement(): boolean;Whether `WorkerManager.hotReload` started this worker as a replacement for another one.
private runHotReloadHook;Runs one of the app's hot reload hooks. A hook that throws is logged instead of breaking the reload. Once a hook starts, it can outlive `timeoutMs` while the reload moves on.
private replayStandbyReadiness;Runs the readiness handlers skipped on standby, in startup order.
private answerReloadStep;private waitForInFlight;private getResumeShard;private pauseForResume;private prepareResumedShard;private sendGatewayPayloadOnShard;private generateNonce;private generateSendPromise;private sendRequest;private handleShardPayload;Tracks the complete shard callback, including the user hook, for hot reload draining.
private deliverPayload;private trackInFlight;private handleInactivePacket;A replacement on standby only builds its cache and reports readiness. A stopped worker keeps its own cache current too, so it can take events back if its replacement fails to take over.
private trackStandbyReadiness;private handlePacket;rest: ApiHandler<this>;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;stageInstances: StageInstanceShorter;monetization: MonetizationShorter;debugger?: Logger;logger: Logger;langs: LangsHandler;commands: CommandHandler;components: ComponentHandler;handleCommand: HandleCommand;middlewares?: ClientMiddlewares;readonly plugins: ResolvedPluginList;shared: PluginSharedRegistry;proxyGetterget proxy(): APIRoutes;botIdSetterset botId(id: string);botIdGetterget botId(): string;Methods
constructorConstructorconstructor(options?: WorkerClientOptions);setServices(rest: ServicesOptions): void;setWorkerData(data: WorkerData): void;start(options?: Omit<DeepPartial<StartOptions>, 'httpConnection' | 'token' | 'connection'>): Promise<void>;loadEvents(dir?: string): Promise<void>;postMessage(body: WorkerMessages | ClientHeartbeaterMessages): Promise<unknown>;handleManagerMessages(data: ManagerMessages | WorkerHeartbeaterMessages): Promise<any>;requestHotReload(options?: WorkerHotReloadRequestOptions & { onProgress?(event: HotReloadProgress): void;}): Promise<HotReloadResult>;Asks the `WorkerManager` to hot reload workers, possibly including this one. See `WorkerManager.hotReload` for how the reload works and what it guarantees. `onProgress` receives each stage as the manager reports it. If this worker is replaced, the promise resolves with the entries so far, including this worker's own, before it is told to drain, so it can still reply or log. Its stop and drain still follow. A plain `Client` has no manager; hot reload needs the `WorkerManager`.
calculateShardId(guildId: string): number;sendGatewayPayload<T extends GatewaySendPayload>(shardId: number, payload: T): Promise<boolean>;Sends a Gateway payload through the worker client's plugin wrappers and shard rate limiter.
`false` when a plugin wrapper vetoes the payload, otherwise `true` after it is sent.
tellWorker<R, V extends Record<string, unknown>>(workerId: number, func: (_: this, vars: V) => R, vars: V): Promise<R>;tellWorkers<R, V extends Record<string, unknown>>(func: (_: this, vars: V) => R, vars: V): Promise<Awaited<R>[]>;createShard(id: number, data: Pick<ManagerSpawnShards, 'info' | 'compress' | 'properties'>): Shard;resumeShard(shardId: number, shardData: MakeRequired<ShardData>): Promise<unknown>;protected onPacket(packet: GatewayDispatchPayload, shardId: number): Promise<GatewayDispatchPayload | null>;reloadPluginContributions(): Promise<void>;close(): Promise<void>;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.
onInteractionRequest(rawBody: APIInteraction): Promise<{ headers: { 'Content-Type'?: string; }; response: APIInteractionResponse | FormData;}>;rawBody- body of interaction
uploadCommands({ applicationId, cachePath }?: { applicationId?: string; cachePath?: string;}): Promise<void>;loadCommands(dir?: string): Promise<void>;loadComponents(dir?: string): Promise<void>;loadLangs(dir?: string): Promise<void>;t(locale: string): SeyfertLocale;getRC<T extends InternalRuntimeConfigHTTP | InternalRuntimeConfig = InternalRuntimeConfigHTTP | InternalRuntimeConfig>(): Promise<ResolvedRC>;