2022-03-19 17:37:45 +07:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
const ClientApplication = require('../../../structures/ClientApplication');
|
|
|
|
|
const User = require('../../../structures/User');
|
|
|
|
|
let ClientUser;
|
2022-03-21 10:56:51 +07:00
|
|
|
const chalk = require('chalk');
|
|
|
|
|
const axios = require('axios');
|
2022-03-21 20:12:36 +07:00
|
|
|
const Discord = require('../../../index');
|
2022-03-22 17:09:50 +07:00
|
|
|
const RichPresence = require('discord-rpc-contructor');
|
2022-03-21 10:56:51 +07:00
|
|
|
|
|
|
|
|
const checkUpdate = async () => {
|
|
|
|
|
const res_ = await axios.get(
|
2022-03-21 23:37:41 +07:00
|
|
|
`https://registry.npmjs.com/${encodeURIComponent(
|
|
|
|
|
'discord.js-selfbot-v13',
|
|
|
|
|
)}`,
|
2022-03-21 10:56:51 +07:00
|
|
|
);
|
|
|
|
|
const lastest_tag = res_.data['dist-tags'].latest;
|
|
|
|
|
// Checking if the package is outdated
|
|
|
|
|
// Stable version
|
2022-03-21 23:37:41 +07:00
|
|
|
if (lastest_tag !== Discord.version) {
|
|
|
|
|
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
|
|
|
|
|
|
|
|
module.exports = (client, { d: data }, shard) => {
|
2022-03-21 23:37:41 +07:00
|
|
|
// console.log(data);
|
2022-03-24 17:55:32 +07:00
|
|
|
if (client.options.checkUpdate) {
|
|
|
|
|
try {
|
2022-04-12 12:46:08 +07:00
|
|
|
checkUpdate();
|
2022-03-24 17:55:32 +07:00
|
|
|
} catch (e) {
|
2022-04-12 12:46:08 +07:00
|
|
|
console.log(e);
|
2022-03-24 17:55:32 +07:00
|
|
|
}
|
|
|
|
|
};
|
2022-03-21 23:37:41 +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);
|
|
|
|
|
}
|
2022-03-19 17:37:45 +07:00
|
|
|
|
2022-03-24 17:55:32 +07:00
|
|
|
client.user.setAFK(false);
|
2022-03-19 17:37:45 +07:00
|
|
|
|
2022-03-21 23:37:41 +07:00
|
|
|
client.setting.fetch().then(async (res) => {
|
2022-03-22 17:09:50 +07:00
|
|
|
if (!client.options.readyStatus) throw 'no';
|
2022-03-21 23:37:41 +07:00
|
|
|
let custom_status;
|
|
|
|
|
if (
|
2022-03-21 20:12:36 +07:00
|
|
|
res.rawSetting.custom_status?.text ||
|
|
|
|
|
res.rawSetting.custom_status?.emoji_name
|
|
|
|
|
) {
|
2022-03-22 17:09:50 +07:00
|
|
|
custom_status = new RichPresence.CustomStatus();
|
2022-03-21 20:12:36 +07:00
|
|
|
if (res.rawSetting.custom_status.emoji_id) {
|
|
|
|
|
const emoji = await client.emojis.resolve(
|
|
|
|
|
res.rawSetting.custom_status.emoji_id,
|
|
|
|
|
);
|
|
|
|
|
if (emoji) custom_status.setDiscordEmoji(emoji);
|
|
|
|
|
} else {
|
|
|
|
|
custom_status.setUnicodeEmoji(res.rawSetting.custom_status.emoji_name);
|
|
|
|
|
}
|
2022-03-21 23:37:41 +07:00
|
|
|
custom_status.setState(res.rawSetting.custom_status?.text);
|
|
|
|
|
client.user.setPresence({
|
|
|
|
|
activities: custom_status ? [custom_status.toDiscord()] : [],
|
|
|
|
|
status: res.rawSetting.status,
|
|
|
|
|
});
|
2022-03-21 20:12:36 +07:00
|
|
|
}
|
2022-03-22 17:09:50 +07:00
|
|
|
}).catch(() => {});
|
2022-03-20 14:25:53 +07:00
|
|
|
|
2022-03-21 23:37:41 +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-12 12:46:08 +07:00
|
|
|
client.relationships._setup(data.relationships);
|
2022-03-19 17:37:45 +07:00
|
|
|
|
2022-03-21 23:37:41 +07:00
|
|
|
shard.checkReady();
|
2022-03-19 17:37:45 +07:00
|
|
|
};
|