mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-10 04:32:35 +01:00
send GUILD_CREATE after READY event (#938)
* Fix lazy guilds being sent before READY event * Make casing consistent
This commit is contained in:
parent
c0b12bc166
commit
78df79df9d
@ -141,18 +141,11 @@ export async function onIdentify(this: WebSocket, data: Payload) {
|
||||
}) as PublicMember[][];
|
||||
let guilds = members.map((x) => ({ ...x.guild, joined_at: x.joined_at }));
|
||||
|
||||
const pending_guilds: typeof guilds = [];
|
||||
// @ts-ignore
|
||||
guilds = guilds.map((guild) => {
|
||||
if (user.bot) {
|
||||
setTimeout(() => {
|
||||
var promise = Send(this, {
|
||||
op: OPCODES.Dispatch,
|
||||
t: EVENTEnum.GuildCreate,
|
||||
s: this.sequence++,
|
||||
d: guild,
|
||||
});
|
||||
if (promise) promise.catch(console.error);
|
||||
}, 500);
|
||||
pending_guilds.push(guild);
|
||||
return { id: guild.id, unavailable: true };
|
||||
}
|
||||
|
||||
@ -314,6 +307,17 @@ export async function onIdentify(this: WebSocket, data: Payload) {
|
||||
d,
|
||||
});
|
||||
|
||||
await Promise.all(
|
||||
pending_guilds.map((guild) =>
|
||||
Send(this, {
|
||||
op: OPCODES.Dispatch,
|
||||
t: EVENTEnum.GuildCreate,
|
||||
s: this.sequence++,
|
||||
d: guild,
|
||||
})?.catch(console.error),
|
||||
),
|
||||
);
|
||||
|
||||
//TODO send READY_SUPPLEMENTAL
|
||||
//TODO send GUILD_MEMBER_LIST_UPDATE
|
||||
//TODO send SESSIONS_REPLACE
|
||||
|
Loading…
Reference in New Issue
Block a user