mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-01 20:46:08 +00:00
fix: mergeOptions & types
This commit is contained in:
parent
af678b88f7
commit
1cb4ab4a46
@ -35,7 +35,7 @@
|
||||
"@biomejs/biome": "1.8.1",
|
||||
"@commitlint/cli": "^19.3.0",
|
||||
"@commitlint/config-conventional": "^19.2.2",
|
||||
"@types/node": "^20.14.6",
|
||||
"@types/node": "^20.14.7",
|
||||
"@types/ws": "^8.5.10",
|
||||
"husky": "^9.0.11",
|
||||
"lint-staged": "^15.2.7",
|
||||
|
36
pnpm-lock.yaml
generated
36
pnpm-lock.yaml
generated
@ -39,13 +39,13 @@ importers:
|
||||
version: 1.8.1
|
||||
'@commitlint/cli':
|
||||
specifier: ^19.3.0
|
||||
version: 19.3.0(@types/node@20.14.6)(typescript@5.5.2)
|
||||
version: 19.3.0(@types/node@20.14.7)(typescript@5.5.2)
|
||||
'@commitlint/config-conventional':
|
||||
specifier: ^19.2.2
|
||||
version: 19.2.2
|
||||
'@types/node':
|
||||
specifier: ^20.14.6
|
||||
version: 20.14.6
|
||||
specifier: ^20.14.7
|
||||
version: 20.14.7
|
||||
'@types/ws':
|
||||
specifier: ^8.5.10
|
||||
version: 8.5.10
|
||||
@ -201,8 +201,8 @@ packages:
|
||||
'@types/conventional-commits-parser@5.0.0':
|
||||
resolution: {integrity: sha512-loB369iXNmAZglwWATL+WRe+CRMmmBPtpolYzIebFaX4YA3x+BEfLqhUAV9WanycKI3TG1IMr5bMJDajDKLlUQ==}
|
||||
|
||||
'@types/node@20.14.6':
|
||||
resolution: {integrity: sha512-JbA0XIJPL1IiNnU7PFxDXyfAwcwVVrOoqyzzyQTyMeVhBzkJVMSkC1LlVsRQ2lpqiY4n6Bb9oCS6lzDKVQxbZw==}
|
||||
'@types/node@20.14.7':
|
||||
resolution: {integrity: sha512-uTr2m2IbJJucF3KUxgnGOZvYbN0QgkGyWxG6973HCpMYFy2KfcgYuIwkJQMQkt1VbBMlvWRbpshFTLxnxCZjKQ==}
|
||||
|
||||
'@types/ws@8.5.10':
|
||||
resolution: {integrity: sha512-vmQSUcfalpIq0R9q7uTo2lXs6eGIpt9wtnLdMv9LVpIjCA/+ufZRozlVoVelIYixx1ugCBKDhn89vnsEGOCx9A==}
|
||||
@ -545,8 +545,8 @@ packages:
|
||||
engines: {node: '>=18.12.0'}
|
||||
hasBin: true
|
||||
|
||||
listr2@8.2.2:
|
||||
resolution: {integrity: sha512-sy0dq+JPS+RAFiFk2K8Nbub7khNmeeoFALNUJ4Wzk34wZKAzaOhEXqGWs4RA5aui0RaM6Hgn7VEKhCj0mlKNLA==}
|
||||
listr2@8.2.3:
|
||||
resolution: {integrity: sha512-Lllokma2mtoniUOS94CcOErHWAug5iu7HOmDrvWgpw8jyQH2fomgB+7lZS4HWZxytUuQwkGOwe49FvwVaA85Xw==}
|
||||
engines: {node: '>=18.0.0'}
|
||||
|
||||
locate-path@7.2.0:
|
||||
@ -909,11 +909,11 @@ snapshots:
|
||||
'@biomejs/cli-win32-x64@1.8.1':
|
||||
optional: true
|
||||
|
||||
'@commitlint/cli@19.3.0(@types/node@20.14.6)(typescript@5.5.2)':
|
||||
'@commitlint/cli@19.3.0(@types/node@20.14.7)(typescript@5.5.2)':
|
||||
dependencies:
|
||||
'@commitlint/format': 19.3.0
|
||||
'@commitlint/lint': 19.2.2
|
||||
'@commitlint/load': 19.2.0(@types/node@20.14.6)(typescript@5.5.2)
|
||||
'@commitlint/load': 19.2.0(@types/node@20.14.7)(typescript@5.5.2)
|
||||
'@commitlint/read': 19.2.1
|
||||
'@commitlint/types': 19.0.3
|
||||
execa: 8.0.1
|
||||
@ -960,7 +960,7 @@ snapshots:
|
||||
'@commitlint/rules': 19.0.3
|
||||
'@commitlint/types': 19.0.3
|
||||
|
||||
'@commitlint/load@19.2.0(@types/node@20.14.6)(typescript@5.5.2)':
|
||||
'@commitlint/load@19.2.0(@types/node@20.14.7)(typescript@5.5.2)':
|
||||
dependencies:
|
||||
'@commitlint/config-validator': 19.0.3
|
||||
'@commitlint/execute-rule': 19.0.0
|
||||
@ -968,7 +968,7 @@ snapshots:
|
||||
'@commitlint/types': 19.0.3
|
||||
chalk: 5.3.0
|
||||
cosmiconfig: 9.0.0(typescript@5.5.2)
|
||||
cosmiconfig-typescript-loader: 5.0.0(@types/node@20.14.6)(cosmiconfig@9.0.0(typescript@5.5.2))(typescript@5.5.2)
|
||||
cosmiconfig-typescript-loader: 5.0.0(@types/node@20.14.7)(cosmiconfig@9.0.0(typescript@5.5.2))(typescript@5.5.2)
|
||||
lodash.isplainobject: 4.0.6
|
||||
lodash.merge: 4.6.2
|
||||
lodash.uniq: 4.5.0
|
||||
@ -1025,15 +1025,15 @@ snapshots:
|
||||
|
||||
'@types/conventional-commits-parser@5.0.0':
|
||||
dependencies:
|
||||
'@types/node': 20.14.6
|
||||
'@types/node': 20.14.7
|
||||
|
||||
'@types/node@20.14.6':
|
||||
'@types/node@20.14.7':
|
||||
dependencies:
|
||||
undici-types: 5.26.5
|
||||
|
||||
'@types/ws@8.5.10':
|
||||
dependencies:
|
||||
'@types/node': 20.14.6
|
||||
'@types/node': 20.14.7
|
||||
|
||||
JSONStream@1.3.5:
|
||||
dependencies:
|
||||
@ -1154,9 +1154,9 @@ snapshots:
|
||||
meow: 12.1.1
|
||||
split2: 4.2.0
|
||||
|
||||
cosmiconfig-typescript-loader@5.0.0(@types/node@20.14.6)(cosmiconfig@9.0.0(typescript@5.5.2))(typescript@5.5.2):
|
||||
cosmiconfig-typescript-loader@5.0.0(@types/node@20.14.7)(cosmiconfig@9.0.0(typescript@5.5.2))(typescript@5.5.2):
|
||||
dependencies:
|
||||
'@types/node': 20.14.6
|
||||
'@types/node': 20.14.7
|
||||
cosmiconfig: 9.0.0(typescript@5.5.2)
|
||||
jiti: 1.21.6
|
||||
typescript: 5.5.2
|
||||
@ -1341,7 +1341,7 @@ snapshots:
|
||||
debug: 4.3.5
|
||||
execa: 8.0.1
|
||||
lilconfig: 3.1.2
|
||||
listr2: 8.2.2
|
||||
listr2: 8.2.3
|
||||
micromatch: 4.0.7
|
||||
pidtree: 0.6.0
|
||||
string-argv: 0.3.2
|
||||
@ -1349,7 +1349,7 @@ snapshots:
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
listr2@8.2.2:
|
||||
listr2@8.2.3:
|
||||
dependencies:
|
||||
cli-truncate: 4.0.0
|
||||
colorette: 2.0.20
|
||||
|
@ -119,7 +119,7 @@ export class Watcher extends ShardManager {
|
||||
}
|
||||
}
|
||||
|
||||
export interface WatcherOptions extends Omit<ShardManagerOptions, 'handlePayload' | 'info' | 'token' | 'intents'> {
|
||||
export interface WatcherOptions extends Omit<ShardManager['options'], 'handlePayload' | 'info' | 'token' | 'intents'> {
|
||||
filePath: string;
|
||||
transpileCommand: string;
|
||||
srcPath: string;
|
||||
|
@ -40,7 +40,7 @@ export function delay<T>(time: number, result?: T): Promise<T> {
|
||||
* @param o The value to check.
|
||||
* @returns `true` if the value is an object, otherwise `false`.
|
||||
*/
|
||||
export function isObject(o: any): boolean {
|
||||
export function isObject(o: any): o is Record<string, unknown> {
|
||||
return o && typeof o === 'object' && !Array.isArray(o);
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@ import { GatewayCloseCodes, GatewayDispatchEvents, GatewayOpcodes } from 'discor
|
||||
import { inflateSync } from 'node:zlib';
|
||||
import type WS from 'ws';
|
||||
import { WebSocket, type CloseEvent, type ErrorEvent } from 'ws';
|
||||
import type { Logger } from '../../common';
|
||||
import { type MakeRequired, MergeOptions, type Logger } from '../../common';
|
||||
import { properties } from '../constants';
|
||||
import { DynamicBucket } from '../structures';
|
||||
import { ConnectTimeout } from '../structures/timeout';
|
||||
@ -35,14 +35,19 @@ export class Shard {
|
||||
bucket: DynamicBucket;
|
||||
offlineSendQueue: ((_?: unknown) => void)[] = [];
|
||||
|
||||
options: MakeRequired<ShardOptions, 'properties' | 'ratelimitOptions'>;
|
||||
|
||||
constructor(
|
||||
public id: number,
|
||||
public options: ShardOptions,
|
||||
options: ShardOptions,
|
||||
) {
|
||||
this.options.ratelimitOptions ??= {
|
||||
rateLimitResetInterval: 60_000,
|
||||
maxRequestsPerRateLimitTick: 120,
|
||||
};
|
||||
this.options = MergeOptions<Shard['options']>(options, {
|
||||
properties,
|
||||
ratelimitOptions: {
|
||||
rateLimitResetInterval: 60_000,
|
||||
maxRequestsPerRateLimitTick: 120,
|
||||
},
|
||||
} as ShardOptions);
|
||||
|
||||
if (options.debugger) this.debugger = options.debugger;
|
||||
|
||||
@ -130,7 +135,7 @@ export class Shard {
|
||||
d: {
|
||||
token: `Bot ${this.options.token}`,
|
||||
compress: this.options.compress,
|
||||
properties: this.options.properties ?? properties,
|
||||
properties: this.options.properties,
|
||||
shard: [this.id, this.options.info.shards],
|
||||
intents: this.options.intents,
|
||||
presence: this.options.presence,
|
||||
@ -264,6 +269,7 @@ export class Shard {
|
||||
|
||||
switch (close.code) {
|
||||
case ShardSocketCloseCodes.Shutdown:
|
||||
//Force disconnect, ignore
|
||||
break;
|
||||
case 1000:
|
||||
case 1001:
|
||||
|
@ -7,6 +7,7 @@ import {
|
||||
import {
|
||||
LogLevels,
|
||||
Logger,
|
||||
type MakeRequired,
|
||||
MergeOptions,
|
||||
lazyLoadPackage,
|
||||
toSnakeCase,
|
||||
@ -24,13 +25,18 @@ let workerData: WorkerData;
|
||||
|
||||
export class ShardManager extends Map<number, Shard> {
|
||||
connectQueue: ConnectQueue;
|
||||
options: ShardManagerOptions;
|
||||
options: MakeRequired<ShardManagerOptions, keyof typeof ShardManagerDefaults>;
|
||||
debugger?: Logger;
|
||||
|
||||
constructor(options: ShardManagerOptions) {
|
||||
super();
|
||||
options.totalShards ??= options.info.shards;
|
||||
this.options = MergeOptions<Required<ShardManagerOptions>>(ShardManagerDefaults, options);
|
||||
this.options = MergeOptions<ShardManager['options']>(
|
||||
ShardManagerDefaults,
|
||||
{
|
||||
totalShards: options.info.shards,
|
||||
} as ShardManagerOptions,
|
||||
options,
|
||||
);
|
||||
this.connectQueue = new ConnectQueue(5.5e3, this.concurrency);
|
||||
|
||||
if (this.options.debug) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user