mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-01 20:46:08 +00:00
Fixes (#231)
* fix: event handling in client.ts and workerclient.ts * fix: optional
This commit is contained in:
parent
aeae6f0e37
commit
91bf30e4b3
@ -159,11 +159,11 @@ export class Client<Ready extends boolean = boolean> extends BaseClient {
|
||||
break;
|
||||
case 'GUILD_CREATE': {
|
||||
if (this.__handleGuilds?.has(packet.d.id)) {
|
||||
this.__handleGuilds.delete(packet.d.id);
|
||||
if (!this.__handleGuilds.size && [...this.gateway.values()].every(shard => shard.data.session_id)) {
|
||||
this.__handleGuilds?.delete(packet.d.id);
|
||||
if (!this.__handleGuilds?.size && [...this.gateway.values()].every(shard => shard.data.session_id)) {
|
||||
await this.events?.runEvent('BOT_READY', this, this.me, -1);
|
||||
}
|
||||
if (!this.__handleGuilds.size) delete this.__handleGuilds;
|
||||
if (!this.__handleGuilds?.size) delete this.__handleGuilds;
|
||||
return this.cache.onPacket(packet);
|
||||
}
|
||||
await this.events?.execute(packet.t, packet, this as Client<true>, shardId);
|
||||
@ -183,7 +183,7 @@ export class Client<Ready extends boolean = boolean> extends BaseClient {
|
||||
case 'READY':
|
||||
if (!this.__handleGuilds) this.__handleGuilds = new Set();
|
||||
for (const g of packet.d.guilds) {
|
||||
this.__handleGuilds.add(g.id);
|
||||
this.__handleGuilds?.add(g.id);
|
||||
}
|
||||
await this.events?.execute(packet.t as never, packet, this as Client<true>, shardId);
|
||||
this.botId = packet.d.user.id;
|
||||
@ -191,7 +191,7 @@ export class Client<Ready extends boolean = boolean> extends BaseClient {
|
||||
this.me = Transformers.ClientUser(this, packet.d.user, packet.d.application) as never;
|
||||
if (
|
||||
!(
|
||||
this.__handleGuilds.size &&
|
||||
this.__handleGuilds?.size &&
|
||||
(this.gateway.options.intents & GatewayIntentBits.Guilds) === GatewayIntentBits.Guilds
|
||||
)
|
||||
) {
|
||||
|
@ -365,15 +365,15 @@ export class WorkerClient<Ready extends boolean = boolean> extends BaseClient {
|
||||
break;
|
||||
case 'GUILD_CREATE': {
|
||||
if (this.__handleGuilds?.has(packet.d.id)) {
|
||||
this.__handleGuilds.delete(packet.d.id);
|
||||
if (!this.__handleGuilds.size && [...this.shards.values()].every(shard => shard.data.session_id)) {
|
||||
this.__handleGuilds?.delete(packet.d.id);
|
||||
if (!this.__handleGuilds?.size && [...this.shards.values()].every(shard => shard.data.session_id)) {
|
||||
this.postMessage({
|
||||
type: 'WORKER_READY',
|
||||
workerId: this.workerId,
|
||||
} as WorkerReady);
|
||||
await this.events?.runEvent('WORKER_READY', this, this.me, -1);
|
||||
}
|
||||
if (!this.__handleGuilds.size) delete this.__handleGuilds;
|
||||
if (!this.__handleGuilds?.size) delete this.__handleGuilds;
|
||||
return this.cache.onPacket(packet);
|
||||
}
|
||||
await this.events?.execute(packet.t, packet, this, shardId);
|
||||
@ -392,7 +392,7 @@ export class WorkerClient<Ready extends boolean = boolean> extends BaseClient {
|
||||
case 'READY':
|
||||
if (!this.__handleGuilds) this.__handleGuilds = new Set();
|
||||
for (const g of packet.d.guilds) {
|
||||
this.__handleGuilds.add(g.id);
|
||||
this.__handleGuilds?.add(g.id);
|
||||
}
|
||||
await this.events?.execute(packet.t as never, packet, this, shardId);
|
||||
this.botId = packet.d.user.id;
|
||||
@ -400,7 +400,8 @@ export class WorkerClient<Ready extends boolean = boolean> extends BaseClient {
|
||||
this.me = Transformers.ClientUser(this, packet.d.user, packet.d.application) as never;
|
||||
if (
|
||||
!(
|
||||
this.__handleGuilds.size && (workerData.intents & GatewayIntentBits.Guilds) === GatewayIntentBits.Guilds
|
||||
this.__handleGuilds?.size &&
|
||||
(workerData.intents & GatewayIntentBits.Guilds) === GatewayIntentBits.Guilds
|
||||
)
|
||||
) {
|
||||
if ([...this.shards.values()].every(shard => shard.data.session_id)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user