mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-14 02:23:31 +01:00
feat(website): Show constructor information (#8540)
This commit is contained in:
@@ -21,6 +21,9 @@ export class SimpleShardingStrategy implements IShardingStrategy {
|
||||
this.throttler = new IdentifyThrottler(manager);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc IShardingStrategy.spawn}
|
||||
*/
|
||||
public async spawn(shardIds: number[]) {
|
||||
const strategyOptions = await managerToFetchingStrategyOptions(this.manager);
|
||||
for (const shardId of shardIds) {
|
||||
@@ -34,6 +37,9 @@ export class SimpleShardingStrategy implements IShardingStrategy {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc IShardingStrategy.connect}
|
||||
*/
|
||||
public async connect() {
|
||||
const promises = [];
|
||||
|
||||
@@ -45,6 +51,9 @@ export class SimpleShardingStrategy implements IShardingStrategy {
|
||||
await Promise.all(promises);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc IShardingStrategy.destroy}
|
||||
*/
|
||||
public async destroy(options?: Omit<WebSocketShardDestroyOptions, 'recover'>) {
|
||||
const promises = [];
|
||||
|
||||
@@ -56,6 +65,9 @@ export class SimpleShardingStrategy implements IShardingStrategy {
|
||||
this.shards.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc IShardingStrategy.send}
|
||||
*/
|
||||
public send(shardId: number, payload: GatewaySendPayload) {
|
||||
const shard = this.shards.get(shardId);
|
||||
if (!shard) throw new Error(`Shard ${shardId} not found`);
|
||||
|
||||
@@ -73,6 +73,9 @@ export class WorkerShardingStrategy implements IShardingStrategy {
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc IShardingStrategy.spawn}
|
||||
*/
|
||||
public async spawn(shardIds: number[]) {
|
||||
const shardsPerWorker = this.options.shardsPerWorker === 'all' ? shardIds.length : this.options.shardsPerWorker;
|
||||
const strategyOptions = await managerToFetchingStrategyOptions(this.manager);
|
||||
@@ -106,6 +109,9 @@ export class WorkerShardingStrategy implements IShardingStrategy {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc IShardingStrategy.connect}
|
||||
*/
|
||||
public async connect() {
|
||||
const promises = [];
|
||||
|
||||
@@ -125,6 +131,9 @@ export class WorkerShardingStrategy implements IShardingStrategy {
|
||||
await Promise.all(promises);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc IShardingStrategy.destroy}
|
||||
*/
|
||||
public async destroy(options: Omit<WebSocketShardDestroyOptions, 'recover'> = {}) {
|
||||
const promises = [];
|
||||
|
||||
@@ -147,6 +156,9 @@ export class WorkerShardingStrategy implements IShardingStrategy {
|
||||
await Promise.all(promises);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc IShardingStrategy.send}
|
||||
*/
|
||||
public send(shardId: number, data: GatewaySendPayload) {
|
||||
const worker = this.#workerByShardId.get(shardId);
|
||||
if (!worker) {
|
||||
|
||||
@@ -203,7 +203,7 @@ export class WebSocketManager extends AsyncEventEmitter<ManagerShardEventsMap> {
|
||||
|
||||
/**
|
||||
* Fetches the gateway information from Discord - or returns it from cache if available
|
||||
* @param force Whether to ignore the cache and force a fresh fetch
|
||||
* @param force - Whether to ignore the cache and force a fresh fetch
|
||||
*/
|
||||
public async fetchGatewayInformation(force = false) {
|
||||
if (this.gatewayInformation) {
|
||||
@@ -222,7 +222,7 @@ export class WebSocketManager extends AsyncEventEmitter<ManagerShardEventsMap> {
|
||||
|
||||
/**
|
||||
* Updates your total shard count on-the-fly, spawning shards as needed
|
||||
* @param shardCount The new shard count to use
|
||||
* @param shardCount - The new shard count to use
|
||||
*/
|
||||
public async updateShardCount(shardCount: number | null) {
|
||||
await this.strategy.destroy({ reason: 'User is adjusting their shards' });
|
||||
|
||||
Reference in New Issue
Block a user