feat: getRC in workerManager

This commit is contained in:
MARCROCK22 2024-12-19 14:16:56 -04:00
parent a0a70066ef
commit d8d6ff6b47
2 changed files with 8 additions and 3 deletions

View File

@ -1,3 +1,4 @@
import type { InternalRuntimeConfig, InternalRuntimeConfigHTTP } from '../../client/base';
import type { Awaitable, DeepPartial, Logger } from '../../common';
import type {
APIGatewayBotInfo,
@ -73,6 +74,8 @@ export interface WorkerManagerOptions extends Omit<ShardManagerOptions, 'handleP
handleWorkerMessage?(message: WorkerMessages): any;
properties?: DeepPartial<NonNullable<ShardManagerOptions['properties']>>;
getRC?(): Awaitable<InternalRuntimeConfig | InternalRuntimeConfigHTTP>;
}
export interface ShardData {

View File

@ -46,7 +46,7 @@ export class WorkerManager extends Map<
return chunks;
}
options: PickPartial<Required<WorkerManagerOptions>, 'adapter' | 'handleWorkerMessage' | 'handlePayload'>;
options: PickPartial<Required<WorkerManagerOptions>, 'adapter' | 'handleWorkerMessage' | 'handlePayload' | 'getRC'>;
debugger?: Logger;
connectQueue!: ConnectQueue;
workerQueue: (() => void)[] = [];
@ -553,9 +553,11 @@ export class WorkerManager extends Map<
}
async start() {
const rc = await BaseClient.prototype.getRC<InternalRuntimeConfig>();
const rc =
((await this.options.getRC?.()) as InternalRuntimeConfig | undefined) ??
(await BaseClient.prototype.getRC<InternalRuntimeConfig>());
this.options.debug ||= rc.debug;
this.options.debug ||= rc.debug ?? false;
this.options.intents ||= rc.intents ?? 0;
this.options.token ??= rc.token;
this.rest ??= new ApiHandler({