mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-02 04:56:07 +00:00
feat: collectors
This commit is contained in:
parent
006a9f390f
commit
48bf52a269
@ -170,6 +170,7 @@ export class Client<Ready extends boolean = boolean> extends BaseClient {
|
||||
//rest of the events
|
||||
default: {
|
||||
await this.cache.onPacket(packet);
|
||||
await this.events?.execute(packet.t, packet, this as Client<true>, shardId);
|
||||
switch (packet.t) {
|
||||
case 'INTERACTION_CREATE':
|
||||
await onInteractionCreate(this, packet.d, shardId);
|
||||
@ -207,7 +208,6 @@ export class Client<Ready extends boolean = boolean> extends BaseClient {
|
||||
break;
|
||||
}
|
||||
}
|
||||
await this.events?.execute(packet.t, packet, this as Client<true>, shardId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ type RunData<T extends SnakeCaseClientNameEvents> = {
|
||||
timeout?: number;
|
||||
onStop?: (reason: string) => unknown;
|
||||
filter: (arg: Awaited<ClientEvents[CamelCase<Lowercase<T>>]>) => Awaitable<boolean>;
|
||||
run: (arg: Awaited<ClientEvents[CamelCase<Lowercase<T>>]>) => unknown;
|
||||
run: (arg: Awaited<ClientEvents[CamelCase<Lowercase<T>>]>, stop: (reason?: string) => void) => unknown;
|
||||
};
|
||||
idle?: NodeJS.Timeout;
|
||||
timeout?: NodeJS.Timeout;
|
||||
@ -89,7 +89,9 @@ export class Collectors {
|
||||
for (const i of collectors) {
|
||||
if (await i.options.filter(data)) {
|
||||
i.idle?.refresh();
|
||||
await i.options.run(data);
|
||||
await i.options.run(data, (reason = 'unknown') => {
|
||||
return this.delete(i.options.event, i.nonce, reason);
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -77,8 +77,8 @@ export class EventHandler extends BaseHandler {
|
||||
break;
|
||||
}
|
||||
|
||||
await this.collectors.run(args[0].t, args[0].d);
|
||||
await this.runEvent(args[0].t, args[1], args[0].d, args[2]);
|
||||
await this.collectors.run(args[0].t, args[0].d);
|
||||
}
|
||||
|
||||
async runEvent(name: GatewayEvents, client: Client | WorkerClient, packet: any, shardId: number) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user