Files
discord.js-selfbot/src/client/websocket/handlers/READY.js

69 lines
1.9 KiB
JavaScript
Raw Normal View History

2022-03-19 17:37:45 +07:00
'use strict';
const ClientApplication = require('../../../structures/ClientApplication');
const User = require('../../../structures/User');
let ClientUser;
const chalk = require('chalk');
const axios = require('axios');
const Discord = require('discord.js-selfbot-v13');
const checkUpdate = async () => {
const res_ = await axios.get(
`https://registry.npmjs.com/${encodeURIComponent('discord.js-selfbot-v13')}`,
);
const lastest_tag = res_.data['dist-tags'].latest;
// Checking if the package is outdated
// Stable version
if (lastest_tag !== Discord.version) {
return console.log(`${chalk.yellowBright(
'[WARNING]',
2022-03-21 11:23:41 +07:00
)} New Discord.js-selfbot-v13 version.
Old Version: ${chalk.redBright(Discord.version)} => New Version: ${chalk.greenBright(lastest_tag)}`);
}
return console.log(
`${chalk.greenBright(
'[OK]',
2022-03-21 11:23:41 +07:00
)} Discord.js-selfbot-v13 is up to date. Version: ${chalk.blueBright(
Discord.version,
)}`,
);
};
2022-03-19 17:37:45 +07:00
module.exports = (client, { d: data }, shard) => {
2022-03-20 14:25:53 +07:00
// console.log(data);
if (client.options.checkUpdate) checkUpdate();
2022-03-19 17:37:45 +07:00
client.session_id = data.session_id;
if (client.user) {
client.user._patch(data.user);
} else {
ClientUser ??= require('../../../structures/ClientUser');
client.user = new ClientUser(client, data.user);
client.users.cache.set(client.user.id, client.user);
}
client.user.setAFK(true);
2022-03-20 14:25:53 +07:00
client.setting.fetch();
2022-03-19 17:37:45 +07:00
for (const guild of data.guilds) {
guild.shardId = shard.id;
client.guilds._add(guild);
}
for (const r of data.relationships) {
if(r.type == 1) {
client.friends.cache.set(r.id, new User(client, r.user));
} else if(r.type == 2) {
client.blocked.cache.set(r.id, new User(client, r.user));
}
}
if (client.application) {
client.application._patch(data.application);
} else {
client.application = new ClientApplication(client, data.application);
}
shard.checkReady();
};