mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-01 20:46:08 +00:00
fix: guildCreate event
This commit is contained in:
parent
23be553844
commit
db6134cf95
@ -181,7 +181,18 @@ export class Client<Ready extends boolean = boolean> extends BaseClient {
|
||||
}
|
||||
await this.events?.execute(packet.t, packet, this as Client<true>, shardId);
|
||||
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)) {
|
||||
await this.events?.runEvent('BOT_READY', this, this.me, -1);
|
||||
}
|
||||
if (!this.__handleGuilds.size) delete this.__handleGuilds;
|
||||
return;
|
||||
}
|
||||
await this.events?.execute(packet.t, packet, this as Client<true>, shardId);
|
||||
break;
|
||||
}
|
||||
//rest of the events
|
||||
default: {
|
||||
await this.events?.execute(packet.t, packet, this as Client<true>, shardId);
|
||||
@ -212,17 +223,6 @@ export class Client<Ready extends boolean = boolean> extends BaseClient {
|
||||
}
|
||||
this.debugger?.debug(`#${shardId}[${packet.d.user.username}](${this.botId}) is online...`);
|
||||
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)) {
|
||||
await this.events?.runEvent('BOT_READY', this, this.me, -1);
|
||||
}
|
||||
if (!this.__handleGuilds.size) delete this.__handleGuilds;
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -333,35 +333,7 @@ export class WorkerClient<Ready extends boolean = boolean> extends BaseClient {
|
||||
|
||||
protected async onPacket(packet: GatewayDispatchPayload, shardId: number) {
|
||||
await this.events?.execute('RAW', packet, this as WorkerClient<true>, shardId);
|
||||
await this.events?.execute(packet.t, packet, this, shardId);
|
||||
switch (packet.t) {
|
||||
case 'READY':
|
||||
for (const g of packet.d.guilds) {
|
||||
this.__handleGuilds?.add(g.id);
|
||||
}
|
||||
this.botId = packet.d.user.id;
|
||||
this.applicationId = packet.d.application.id;
|
||||
this.me = new ClientUser(this, packet.d.user, packet.d.application) as never;
|
||||
if (
|
||||
!(this.__handleGuilds?.size && (workerData.intents & GatewayIntentBits.Guilds) === GatewayIntentBits.Guilds)
|
||||
) {
|
||||
if ([...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);
|
||||
}
|
||||
delete this.__handleGuilds;
|
||||
}
|
||||
this.debugger?.debug(`#${shardId} [${packet.d.user.username}](${this.botId}) is online...`);
|
||||
break;
|
||||
case 'INTERACTION_CREATE':
|
||||
await onInteractionCreate(this, packet.d, shardId);
|
||||
break;
|
||||
case 'MESSAGE_CREATE':
|
||||
await onMessageCreate(this, packet.d, shardId);
|
||||
break;
|
||||
case 'GUILD_CREATE': {
|
||||
if (this.__handleGuilds?.has(packet.d.id)) {
|
||||
this.__handleGuilds.delete(packet.d.id);
|
||||
@ -375,6 +347,44 @@ export class WorkerClient<Ready extends boolean = boolean> extends BaseClient {
|
||||
if (!this.__handleGuilds.size) delete this.__handleGuilds;
|
||||
return;
|
||||
}
|
||||
await this.events?.execute(packet.t, packet, this, shardId);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
await this.events?.execute(packet.t, packet, this, shardId);
|
||||
switch (packet.t) {
|
||||
case 'READY':
|
||||
for (const g of packet.d.guilds) {
|
||||
this.__handleGuilds?.add(g.id);
|
||||
}
|
||||
this.botId = packet.d.user.id;
|
||||
this.applicationId = packet.d.application.id;
|
||||
this.me = new ClientUser(this, packet.d.user, packet.d.application) as never;
|
||||
if (
|
||||
!(
|
||||
this.__handleGuilds?.size &&
|
||||
(workerData.intents & GatewayIntentBits.Guilds) === GatewayIntentBits.Guilds
|
||||
)
|
||||
) {
|
||||
if ([...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);
|
||||
}
|
||||
delete this.__handleGuilds;
|
||||
}
|
||||
this.debugger?.debug(`#${shardId} [${packet.d.user.username}](${this.botId}) is online...`);
|
||||
break;
|
||||
case 'INTERACTION_CREATE':
|
||||
await onInteractionCreate(this, packet.d, shardId);
|
||||
break;
|
||||
case 'MESSAGE_CREATE':
|
||||
await onMessageCreate(this, packet.d, shardId);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user