mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-14 10:33:30 +01:00
Cleanup Part 2: Electric Boogaloo (Reloaded) (#594)
* Cleanup Part 2: Electric Boogaloo (Reloaded) * Moar cleanup * Tweak NOT_A_PERMISSION error
This commit is contained in:
committed by
Amish Shah
parent
5a9c42061f
commit
0b908f5bce
@@ -4,40 +4,28 @@ const getStructure = name => require(`../../../../structures/${name}`);
|
||||
const ClientUser = getStructure('ClientUser');
|
||||
|
||||
class ReadyHandler extends AbstractHandler {
|
||||
|
||||
handle(packet) {
|
||||
const data = packet.d;
|
||||
const client = this.packetManager.client;
|
||||
const data = packet.d;
|
||||
|
||||
const clientUser = new ClientUser(client, data.user);
|
||||
client.user = clientUser;
|
||||
client.readyTime = Date.now();
|
||||
client.users.set(clientUser.id, clientUser);
|
||||
for (const guild of data.guilds) {
|
||||
client.dataManager.newGuild(guild);
|
||||
}
|
||||
|
||||
for (const privateDM of data.private_channels) {
|
||||
client.dataManager.newChannel(privateDM);
|
||||
}
|
||||
|
||||
if (!client.user.bot) {
|
||||
client.setInterval(client.syncGuilds.bind(client), 30000);
|
||||
}
|
||||
for (const guild of data.guilds) client.dataManager.newGuild(guild);
|
||||
for (const privateDM of data.private_channels) client.dataManager.newChannel(privateDM);
|
||||
|
||||
if (!client.user.bot) client.setInterval(client.syncGuilds.bind(client), 30000);
|
||||
client.once('ready', client.syncGuilds.bind(client));
|
||||
|
||||
client.setTimeout(() => {
|
||||
if (!client.ws.normalReady) {
|
||||
client.ws._emitReady(false);
|
||||
}
|
||||
if (!client.ws.normalReady) client.ws._emitReady(false);
|
||||
}, 1200 * data.guilds.length);
|
||||
|
||||
this.packetManager.ws.sessionID = data.session_id;
|
||||
|
||||
this.packetManager.ws.checkIfReady();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = ReadyHandler;
|
||||
|
||||
Reference in New Issue
Block a user