mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-04 14:06: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
|
//rest of the events
|
||||||
default: {
|
default: {
|
||||||
await this.cache.onPacket(packet);
|
await this.cache.onPacket(packet);
|
||||||
|
await this.events?.execute(packet.t, packet, this as Client<true>, shardId);
|
||||||
switch (packet.t) {
|
switch (packet.t) {
|
||||||
case 'INTERACTION_CREATE':
|
case 'INTERACTION_CREATE':
|
||||||
await onInteractionCreate(this, packet.d, shardId);
|
await onInteractionCreate(this, packet.d, shardId);
|
||||||
@ -207,7 +208,6 @@ export class Client<Ready extends boolean = boolean> extends BaseClient {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await this.events?.execute(packet.t, packet, this as Client<true>, shardId);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ type RunData<T extends SnakeCaseClientNameEvents> = {
|
|||||||
timeout?: number;
|
timeout?: number;
|
||||||
onStop?: (reason: string) => unknown;
|
onStop?: (reason: string) => unknown;
|
||||||
filter: (arg: Awaited<ClientEvents[CamelCase<Lowercase<T>>]>) => Awaitable<boolean>;
|
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;
|
idle?: NodeJS.Timeout;
|
||||||
timeout?: NodeJS.Timeout;
|
timeout?: NodeJS.Timeout;
|
||||||
@ -89,7 +89,9 @@ export class Collectors {
|
|||||||
for (const i of collectors) {
|
for (const i of collectors) {
|
||||||
if (await i.options.filter(data)) {
|
if (await i.options.filter(data)) {
|
||||||
i.idle?.refresh();
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,8 +77,8 @@ export class EventHandler extends BaseHandler {
|
|||||||
break;
|
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.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) {
|
async runEvent(name: GatewayEvents, client: Client | WorkerClient, packet: any, shardId: number) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user