seyfert 2.1.1-dev-12341742427.0 → 2.1.1-dev-12401160313.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/events/handler.js +9 -24
- package/package.json +1 -1
package/lib/events/handler.js
CHANGED
|
@@ -164,44 +164,29 @@ class EventHandler extends common_1.BaseHandler {
|
|
|
164
164
|
}
|
|
165
165
|
async runEvent(name, client, packet, shardId, runCache = true) {
|
|
166
166
|
const Event = this.values[name];
|
|
167
|
-
if (!Event) {
|
|
168
|
-
return runCache
|
|
169
|
-
? this.client.cache.onPacket({
|
|
170
|
-
t: name,
|
|
171
|
-
d: packet,
|
|
172
|
-
})
|
|
173
|
-
: undefined;
|
|
174
|
-
}
|
|
175
167
|
try {
|
|
176
|
-
if (Event.data.once && Event.fired) {
|
|
177
|
-
return
|
|
178
|
-
? this.client.cache.onPacket({
|
|
179
|
-
t: name,
|
|
180
|
-
d: packet,
|
|
181
|
-
})
|
|
182
|
-
: undefined;
|
|
168
|
+
if (!Event || (Event.data.once && Event.fired)) {
|
|
169
|
+
return;
|
|
183
170
|
}
|
|
184
171
|
Event.fired = true;
|
|
185
172
|
const hook = await RawEvents[name]?.(client, packet);
|
|
173
|
+
await Event.run(hook, client, shardId);
|
|
174
|
+
}
|
|
175
|
+
catch (e) {
|
|
176
|
+
await this.onFail(name, e);
|
|
177
|
+
}
|
|
178
|
+
finally {
|
|
186
179
|
if (runCache)
|
|
187
180
|
await this.client.cache.onPacket({
|
|
188
181
|
t: name,
|
|
189
182
|
d: packet,
|
|
190
183
|
});
|
|
191
|
-
await Event.run(hook, client, shardId);
|
|
192
|
-
}
|
|
193
|
-
catch (e) {
|
|
194
|
-
await this.onFail(name, e);
|
|
195
184
|
}
|
|
196
185
|
}
|
|
197
186
|
async runCustom(name, ...args) {
|
|
198
187
|
const Event = this.values[name];
|
|
199
|
-
if (!Event) {
|
|
200
|
-
// @ts-expect-error
|
|
201
|
-
return this.client.collectors.run(name, args, this.client);
|
|
202
|
-
}
|
|
203
188
|
try {
|
|
204
|
-
if (Event.data.once && Event.fired) {
|
|
189
|
+
if (!Event || (Event.data.once && Event.fired)) {
|
|
205
190
|
// @ts-expect-error
|
|
206
191
|
return this.client.collectors.run(name, args, this.client);
|
|
207
192
|
}
|