mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-02 21:16:09 +00:00
fix(core): method stop
This commit is contained in:
parent
02b8bd0d28
commit
0fcc92ab26
@ -1,10 +1,10 @@
|
||||
import { GatewayIntentBits, Identify, When } from '@biscuitland/common';
|
||||
import type { BiscuitRESTOptions, CDNRoutes, Routes } from '@biscuitland/rest';
|
||||
import { BiscuitREST, CDN, Router } from '@biscuitland/rest';
|
||||
import { GatewayEvents, ShardManager, ShardManagerOptions } from '@biscuitland/ws';
|
||||
import EventEmitter2 from 'eventemitter2';
|
||||
import { MainManager, getBotIdFromToken } from '.';
|
||||
import { Handler, actionHandler } from './events/handler';
|
||||
import { GatewayIntentBits, Identify, When } from "@biscuitland/common";
|
||||
import type { BiscuitRESTOptions, CDNRoutes, Routes } from "@biscuitland/rest";
|
||||
import { BiscuitREST, CDN, Router } from "@biscuitland/rest";
|
||||
import { GatewayEvents, ShardManager, ShardManagerOptions } from "@biscuitland/ws";
|
||||
import EventEmitter2 from "eventemitter2";
|
||||
import { MainManager, getBotIdFromToken } from ".";
|
||||
import { Handler, actionHandler } from "./events/handler";
|
||||
|
||||
export class Session<On extends boolean = boolean> extends EventEmitter2 {
|
||||
constructor(public options: BiscuitOptions) {
|
||||
@ -67,7 +67,7 @@ export class Session<On extends boolean = boolean> extends EventEmitter2 {
|
||||
if (!rest) {
|
||||
return new BiscuitREST({
|
||||
token: this.options.token,
|
||||
...this.options.defaultRestOptions
|
||||
...this.options.defaultRestOptions,
|
||||
});
|
||||
}
|
||||
|
||||
@ -75,7 +75,7 @@ export class Session<On extends boolean = boolean> extends EventEmitter2 {
|
||||
return rest;
|
||||
}
|
||||
|
||||
throw new Error('[CORE] REST not found');
|
||||
throw new Error("[CORE] REST not found");
|
||||
}
|
||||
|
||||
async start() {
|
||||
@ -92,10 +92,10 @@ export class Session<On extends boolean = boolean> extends EventEmitter2 {
|
||||
// @ts-expect-error
|
||||
actionHandler([ctx, { t, d }, shard]);
|
||||
},
|
||||
...this.options.defaultGatewayOptions
|
||||
...this.options.defaultGatewayOptions,
|
||||
});
|
||||
|
||||
ctx.once('READY', (payload) => {
|
||||
ctx.once("READY", (payload) => {
|
||||
const { user, application } = payload;
|
||||
this.botId = user.id;
|
||||
this.applicationId = application.id;
|
||||
@ -106,16 +106,16 @@ export class Session<On extends boolean = boolean> extends EventEmitter2 {
|
||||
|
||||
async stop() {
|
||||
this.removeAllListeners();
|
||||
await this.gateway.explode();
|
||||
await this.gateway.disconnectAll();
|
||||
}
|
||||
}
|
||||
|
||||
export type HandlePayload = Pick<ShardManagerOptions, 'handlePayload'>['handlePayload'];
|
||||
export type HandlePayload = Pick<ShardManagerOptions, "handlePayload">["handlePayload"];
|
||||
|
||||
export interface BiscuitOptions {
|
||||
token: string;
|
||||
intents: number | GatewayIntentBits;
|
||||
rest?: BiscuitREST;
|
||||
defaultRestOptions?: Partial<BiscuitRESTOptions>;
|
||||
defaultGatewayOptions?: Identify<Partial<Omit<ShardManagerOptions, 'token' | 'intents'>>>;
|
||||
defaultGatewayOptions?: Identify<Partial<Omit<ShardManagerOptions, "token" | "intents">>>;
|
||||
}
|
||||
|
@ -108,8 +108,11 @@ export class ShardManager extends Collection<number, Shard> {
|
||||
|
||||
disconnectAll() {
|
||||
this.logger.info("Disconnect all shards");
|
||||
return new Promise((resolve) => {
|
||||
// biome-ignore lint/complexity/noForEach: In maps, for each and for of have same performance
|
||||
return this.forEach((shard) => shard.disconnect());
|
||||
this.forEach((shard) => shard.disconnect());
|
||||
resolve(null);
|
||||
});
|
||||
}
|
||||
|
||||
setShardPresence(shardId: number, payload: GatewayUpdatePresence["d"]) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user