mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-01 20:46:08 +00:00
fix: events flow
This commit is contained in:
parent
03d7e5bda8
commit
f9c5f46d50
@ -183,44 +183,28 @@ export class EventHandler extends BaseHandler {
|
||||
runCache = true,
|
||||
) {
|
||||
const Event = this.values[name];
|
||||
if (!Event) {
|
||||
return runCache
|
||||
? this.client.cache.onPacket({
|
||||
t: name,
|
||||
d: packet,
|
||||
} as GatewayDispatchPayload)
|
||||
: undefined;
|
||||
}
|
||||
try {
|
||||
if (Event.data.once && Event.fired) {
|
||||
return runCache
|
||||
? this.client.cache.onPacket({
|
||||
t: name,
|
||||
d: packet,
|
||||
} as GatewayDispatchPayload)
|
||||
: undefined;
|
||||
if (!Event || (Event.data.once && Event.fired)) {
|
||||
return;
|
||||
}
|
||||
Event.fired = true;
|
||||
const hook = await RawEvents[name]?.(client, packet as never);
|
||||
await (Event.run as any)(hook, client, shardId);
|
||||
} catch (e) {
|
||||
await this.onFail(name, e);
|
||||
} finally {
|
||||
if (runCache)
|
||||
await this.client.cache.onPacket({
|
||||
t: name,
|
||||
d: packet,
|
||||
} as GatewayDispatchPayload);
|
||||
await (Event.run as any)(hook, client, shardId);
|
||||
} catch (e) {
|
||||
await this.onFail(name, e);
|
||||
}
|
||||
}
|
||||
|
||||
async runCustom<T extends CustomEventsKeys>(name: T, ...args: ResolveEventRunParams<T>) {
|
||||
const Event = this.values[name];
|
||||
if (!Event) {
|
||||
// @ts-expect-error
|
||||
return this.client.collectors.run(name, args, this.client);
|
||||
}
|
||||
try {
|
||||
if (Event.data.once && Event.fired) {
|
||||
if (!Event || (Event.data.once && Event.fired)) {
|
||||
// @ts-expect-error
|
||||
return this.client.collectors.run(name, args, this.client);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user