mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-04 05:56:09 +00:00
feat(core): stop session
This commit is contained in:
parent
75401227ca
commit
4cf1cad35e
@ -1,11 +1,10 @@
|
|||||||
|
import { GatewayIntentBits, Identify, When } from '@biscuitland/common';
|
||||||
import type { BiscuitRESTOptions, CDNRoutes, Routes } from '@biscuitland/rest';
|
import type { BiscuitRESTOptions, CDNRoutes, Routes } from '@biscuitland/rest';
|
||||||
import { CDN, BiscuitREST, Router } from '@biscuitland/rest';
|
import { BiscuitREST, CDN, Router } from '@biscuitland/rest';
|
||||||
import { Identify, When } from '@biscuitland/common';
|
import { CreateGatewayManagerOptions, GatewayEvents, GatewayManager } from '@biscuitland/ws';
|
||||||
import EventEmitter2 from 'eventemitter2';
|
import EventEmitter2 from 'eventemitter2';
|
||||||
import { MainManager, getBotIdFromToken } from '.';
|
import { MainManager, getBotIdFromToken } from '.';
|
||||||
import { GatewayManager, CreateGatewayManagerOptions, GatewayEvents } from '@biscuitland/ws';
|
import { Handler, actionHandler } from './events/handler';
|
||||||
import { GatewayIntentBits } from '@biscuitland/common';
|
|
||||||
import { actionHandler, Handler } from './events/handler';
|
|
||||||
|
|
||||||
export class Session<On extends boolean = boolean> extends EventEmitter2 {
|
export class Session<On extends boolean = boolean> extends EventEmitter2 {
|
||||||
constructor(public options: BiscuitOptions) {
|
constructor(public options: BiscuitOptions) {
|
||||||
@ -67,8 +66,8 @@ export class Session<On extends boolean = boolean> extends EventEmitter2 {
|
|||||||
private createRest(rest: any) {
|
private createRest(rest: any) {
|
||||||
if (!rest) {
|
if (!rest) {
|
||||||
return new BiscuitREST({
|
return new BiscuitREST({
|
||||||
...this.options.defaultRestOptions,
|
token: this.options.token,
|
||||||
token: this.options.token
|
...this.options.defaultRestOptions
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,6 +102,11 @@ export class Session<On extends boolean = boolean> extends EventEmitter2 {
|
|||||||
|
|
||||||
await ctx.gateway.spawnShards();
|
await ctx.gateway.spawnShards();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async stop(code = 1000, error = 'Stopped') {
|
||||||
|
this.removeAllListeners();
|
||||||
|
await this.gateway.shutdown(code, error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export type HandlePayload = Pick<CreateGatewayManagerOptions, 'handlePayload'>['handlePayload'];
|
export type HandlePayload = Pick<CreateGatewayManagerOptions, 'handlePayload'>['handlePayload'];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user