2022-03-19 17:37:45 +07:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
let ClientUser;
|
2022-03-21 10:56:51 +07:00
|
|
|
const axios = require('axios');
|
2022-04-16 19:01:05 +07:00
|
|
|
const chalk = require('chalk');
|
2022-03-22 17:09:50 +07:00
|
|
|
const RichPresence = require('discord-rpc-contructor');
|
2022-04-16 19:01:05 +07:00
|
|
|
const Discord = require('../../../index');
|
2022-03-21 10:56:51 +07:00
|
|
|
|
|
|
|
|
const checkUpdate = async () => {
|
2022-04-16 17:44:43 +07:00
|
|
|
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 && Discord.version.includes('-') == false) {
|
|
|
|
|
return console.log(`${chalk.yellowBright('[WARNING]')} New Discord.js-selfbot-v13 version.
|
|
|
|
|
Old Version: ${chalk.redBright(Discord.version)} => New Version: ${chalk.greenBright(lastest_tag)}`);
|
|
|
|
|
}
|
|
|
|
|
return console.log(
|
|
|
|
|
`${chalk.greenBright('[OK]')} Discord.js-selfbot-v13 is up to date. Version: ${chalk.blueBright(Discord.version)}`,
|
|
|
|
|
);
|
2022-03-21 10:56:51 +07:00
|
|
|
};
|
2022-03-19 17:37:45 +07:00
|
|
|
|
2022-04-16 17:44:43 +07:00
|
|
|
const customStatusAuto = async client => {
|
|
|
|
|
let custom_status;
|
2022-04-16 19:01:05 +07:00
|
|
|
if (client.setting.rawSetting.custom_status?.text || client.setting.rawSetting.custom_status?.emoji_name) {
|
2022-04-16 17:44:43 +07:00
|
|
|
custom_status = new RichPresence.CustomStatus();
|
|
|
|
|
if (client.setting.rawSetting.custom_status.emoji_id) {
|
|
|
|
|
const emoji = await client.emojis.resolve(client.setting.rawSetting.custom_status.emoji_id);
|
|
|
|
|
if (emoji) custom_status.setDiscordEmoji(emoji);
|
|
|
|
|
} else {
|
|
|
|
|
custom_status.setUnicodeEmoji(client.setting.rawSetting.custom_status.emoji_name);
|
|
|
|
|
}
|
|
|
|
|
custom_status.setState(client.setting.rawSetting.custom_status?.text);
|
|
|
|
|
client.user.setPresence({
|
|
|
|
|
activities: custom_status ? [custom_status.toDiscord()] : [],
|
|
|
|
|
status: client.setting.rawSetting.status,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
};
|
2022-04-14 21:32:11 +07:00
|
|
|
|
2022-03-19 17:37:45 +07:00
|
|
|
module.exports = (client, { d: data }, shard) => {
|
2022-04-16 17:44:43 +07:00
|
|
|
if (client.options.checkUpdate) {
|
|
|
|
|
try {
|
|
|
|
|
checkUpdate();
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.log(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
|
}
|
2022-03-19 17:37:45 +07:00
|
|
|
|
2022-04-16 17:44:43 +07:00
|
|
|
client.user.setAFK(false);
|
2022-03-19 17:37:45 +07:00
|
|
|
|
2022-04-16 17:44:43 +07:00
|
|
|
client.setting._patch(data.user_settings);
|
2022-04-14 21:32:11 +07:00
|
|
|
|
2022-04-16 17:44:43 +07:00
|
|
|
client.user.connectedAccounts = data.connected_accounts ?? [];
|
2022-04-14 21:32:11 +07:00
|
|
|
|
2022-04-16 17:44:43 +07:00
|
|
|
for (const [userid, note] of Object.entries(data.notes)) {
|
|
|
|
|
client.user.notes.set(userid, note);
|
|
|
|
|
}
|
2022-04-14 21:32:11 +07:00
|
|
|
|
2022-04-16 17:44:43 +07:00
|
|
|
for (const private_channel of data.private_channels) {
|
|
|
|
|
client.channels._add(private_channel);
|
|
|
|
|
}
|
2022-04-14 21:32:11 +07:00
|
|
|
|
2022-04-16 17:44:43 +07:00
|
|
|
if (client.options.readyStatus) {
|
|
|
|
|
customStatusAuto(client);
|
|
|
|
|
}
|
2022-04-14 21:32:11 +07:00
|
|
|
|
2022-04-16 17:44:43 +07:00
|
|
|
/**
|
2022-04-16 19:01:05 +07:00
|
|
|
* Read_state: Return Array:
|
2022-04-16 17:44:43 +07:00
|
|
|
* {
|
|
|
|
|
* mention_count: 14, // ok it's ping count
|
|
|
|
|
* last_pin_timestamp: '1970-01-01T00:00:00+00:00', // why discord ?
|
|
|
|
|
* last_message_id: 0, // :)
|
|
|
|
|
* id: '840218426969817119' // channel id
|
|
|
|
|
* },
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*
|
2022-04-14 21:32:11 +07:00
|
|
|
for (const object of data.read_state) {
|
|
|
|
|
if (object.mention_count == 0) continue;
|
|
|
|
|
client.user.messageMentions.set(object.id, object);
|
|
|
|
|
}
|
|
|
|
|
*/
|
2022-03-20 14:25:53 +07:00
|
|
|
|
2022-04-16 17:44:43 +07:00
|
|
|
for (const guild of data.guilds) {
|
|
|
|
|
guild.shardId = shard.id;
|
|
|
|
|
client.guilds._add(guild);
|
|
|
|
|
}
|
2022-03-19 17:37:45 +07:00
|
|
|
|
2022-04-16 17:44:43 +07:00
|
|
|
client.relationships._setup(data.relationships);
|
2022-03-19 17:37:45 +07:00
|
|
|
|
2022-04-16 17:44:43 +07:00
|
|
|
shard.checkReady();
|
2022-03-19 17:37:45 +07:00
|
|
|
};
|