March 7th c165824419 v2.1.0
fix: ClientUser.notes return empty Collection
fix: Recieve messages from large servers #72
feat: checkUpdate return Debug event (not console.log)
feat: RelationshipAdd event, param type return RelationshipTypes
feat: online status when login
feat: fix documents
2022-06-06 00:42:08 +07:00

46 lines
1.1 KiB
JavaScript

'use strict';
const { Events, Opcodes, Status } = require('../../../util/Constants');
// Receive messages in large guilds
const run = (client, guild) => {
client.ws.broadcast({
op: Opcodes.LAZY_REQUEST,
d: {
guild_id: guild.id,
typing: true,
threads: false,
activities: true,
thread_member_lists: [],
members: [],
channels: {
// [guild.channels.cache.first().id]: [[0, 99]],
},
},
});
};
module.exports = (client, { d: data }, shard) => {
let guild = client.guilds.cache.get(data.id);
if (guild) {
if (!guild.available && !data.unavailable) {
// A newly available guild
guild._patch(data);
run(client, guild);
}
} else {
// A new guild
data.shardId = shard.id;
guild = client.guilds._add(data);
if (client.ws.status === Status.READY) {
/**
* Emitted whenever the client joins a guild.
* @event Client#guildCreate
* @param {Guild} guild The created guild
*/
client.emit(Events.GUILD_CREATE, guild);
run(client, guild);
}
}
};