refactor: revert "feat: base plugin lib idea (#2308)" (#2336)

* Revert "feat: base plugin lib idea (#2308)"

This reverts commit ffe7cdbc6f.

* fmt
This commit is contained in:
ITOH
2022-07-02 14:24:43 +01:00
committed by GitHub
parent f57b2274e0
commit 03996c5f58
346 changed files with 786 additions and 856 deletions
-7
View File
@@ -1,7 +0,0 @@
import { GatewayManager } from "./manager/gatewayManager.ts";
export function calculateShardId(gateway: GatewayManager, guildId: bigint) {
if (gateway.manager.totalShards === 1) return 0;
return Number((guildId >> 22n) % BigInt(gateway.manager.totalShards - 1));
}
+6 -4
View File
@@ -1,6 +1,8 @@
import { GetGatewayBot } from "../../transformers/gatewayBot.ts";
import { DiscordGatewayPayload } from "../../types/discord.ts";
import { GatewayBot, PickPartial } from "../../types/shared.ts";
import { GatewayIntents, MakeRequired, OmitFirstFnArg, PickPartial } from "../../types/shared.ts";
import { LeakyBucket } from "../../util/bucket.ts";
import { Collection } from "../../util/collection.ts";
import { CreateShard, createShard } from "../shard/createShard.ts";
import { Shard, ShardGatewayConfig } from "../shard/types.ts";
import { calculateTotalShards } from "./calculateTotalShards.ts";
@@ -46,7 +48,7 @@ export function createGatewayManager(
/** The max concurrency buckets.
* Those will be created when the `spawnShards` (which calls `prepareBuckets` under the hood) function gets called.
*/
buckets: new Map<
buckets: new Collection<
number,
{
workers: { id: number; queue: number[] }[];
@@ -220,7 +222,7 @@ export interface CreateGatewayManager {
lastShardId: number;
/** Important data which is used by the manager to connect shards to the gateway. */
gatewayBot: GatewayBot;
gatewayBot: GetGatewayBot;
gatewayConfig: PickPartial<ShardGatewayConfig, "token">;
@@ -228,7 +230,7 @@ export interface CreateGatewayManager {
createShardOptions?: Omit<CreateShard, "id" | "totalShards" | "requestIdentify" | "gatewayConfig">;
/** Stored as bucketId: { workers: [workerId, [ShardIds]], createNextShard: boolean } */
buckets: Map<
buckets: Collection<
number,
{
workers: { id: number; queue: number[] }[];
+1 -1
View File
@@ -1,4 +1,4 @@
import { delay } from "../../util/delay.ts";
import { delay } from "../../util/utils.ts";
import { GatewayManager } from "./gatewayManager.ts";
export async function stop(gateway: GatewayManager, code: number, reason: string) {
+3 -2
View File
@@ -12,6 +12,7 @@ import {
ShardSocketRequest,
ShardState,
} from "./types.ts";
import { StatusUpdate } from "../../helpers/misc/editShardStatus.ts";
import { startHeartbeating } from "./startHeartbeating.ts";
import { stopHeartbeating } from "./stopHeartbeating.ts";
import { resume } from "./resume.ts";
@@ -23,7 +24,7 @@ import { connect } from "./connect.ts";
import { close } from "./close.ts";
import { shutdown } from "./shutdown.ts";
import { isOpen } from "./isOpen.ts";
import { DiscordGatewayPayload, DiscordStatusUpdate } from "../../types/discord.ts";
import { DiscordGatewayPayload } from "../../types/discord.ts";
import { GatewayIntents, PickPartial } from "../../types/shared.ts";
import { API_VERSION } from "../../util/constants.ts";
@@ -274,7 +275,7 @@ export interface CreateShard {
isOpen?: typeof isOpen;
/** Function which can be overwritten in order to get the shards presence. */
makePresence?(shardId: number): Promise<DiscordStatusUpdate> | DiscordStatusUpdate;
makePresence?(shardId: number): Promise<StatusUpdate> | StatusUpdate;
/** The maximum of requests which can be send to discord per rate limit tick.
* Typically this value should not be changed.
+1 -1
View File
@@ -1,7 +1,7 @@
import { DiscordGatewayPayload, DiscordHello, DiscordReady } from "../../types/discord.ts";
import { GatewayOpcodes } from "../../types/shared.ts";
import { createLeakyBucket } from "../../util/bucket.ts";
import { delay } from "../../util/delay.ts";
import { delay } from "../../util/utils.ts";
import { decompressWith } from "./deps.ts";
import { GATEWAY_RATE_LIMIT_RESET_INTERVAL, Shard, ShardState } from "./types.ts";
+2
View File
@@ -1,5 +1,7 @@
import { StatusUpdate } from "../../helpers/misc/editShardStatus.ts";
import { DiscordGatewayPayload } from "../../types/discord.ts";
import { GatewayOpcodes } from "../../types/shared.ts";
import { LeakyBucket } from "../../util/bucket.ts";
import { createShard } from "./createShard.ts";
// TODO: think whether we also need an identifiedShard function