2022-03-19 17:37:45 +07:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
let ClientUser;
|
2022-10-15 12:26:52 +07:00
|
|
|
const { VoiceConnection } = require('@discordjs/voice');
|
2022-04-16 19:01:05 +07:00
|
|
|
const chalk = require('chalk');
|
2022-05-11 20:19:04 +07:00
|
|
|
const { Events, Opcodes } = require('../../../util/Constants');
|
2022-10-15 12:26:52 +07:00
|
|
|
const { VoiceConnection: VoiceConnection_patch } = require('../../../util/Voice');
|
2022-11-15 20:06:03 +07:00
|
|
|
let firstReady = false;
|
|
|
|
|
|
|
|
|
|
function patchVoice(client) {
|
|
|
|
|
try {
|
|
|
|
|
/* eslint-disable */
|
|
|
|
|
VoiceConnection.prototype.configureNetworking = VoiceConnection_patch.prototype.configureNetworking;
|
|
|
|
|
client.emit(
|
|
|
|
|
'debug',
|
|
|
|
|
`${chalk.greenBright('[OK]')} Patched ${chalk.cyanBright(
|
|
|
|
|
'VoiceConnection.prototype.configureNetworking',
|
2023-04-07 21:39:47 +07:00
|
|
|
)} [${chalk.bgMagentaBright('@discordjs/voice')} - ${chalk.redBright('v0.16.0')}]`,
|
2022-11-15 20:06:03 +07:00
|
|
|
);
|
|
|
|
|
/* eslint-enable */
|
|
|
|
|
} catch (e) {
|
|
|
|
|
client.emit(
|
|
|
|
|
'debug',
|
|
|
|
|
`${chalk.redBright('[Fail]')} Patched ${chalk.cyanBright(
|
|
|
|
|
'VoiceConnection.prototype.configureNetworking',
|
2023-04-07 21:39:47 +07:00
|
|
|
)} [${chalk.bgMagentaBright('@discordjs/voice')} - ${chalk.redBright('v0.16.0')}]\n${e.stack}`,
|
2022-11-15 20:06:03 +07:00
|
|
|
);
|
|
|
|
|
client.emit(
|
|
|
|
|
Events.ERROR,
|
|
|
|
|
`${chalk.redBright('[Fail]')} Patched ${chalk.cyanBright(
|
|
|
|
|
'VoiceConnection.prototype.configureNetworking',
|
2023-04-07 21:39:47 +07:00
|
|
|
)} [${chalk.bgMagentaBright('@discordjs/voice')} - ${chalk.redBright('v0.16.0')}]`,
|
2022-11-15 20:06:03 +07:00
|
|
|
);
|
|
|
|
|
client.emit(
|
|
|
|
|
Events.ERROR,
|
|
|
|
|
`${chalk.redBright('[Error]')} Please install ${chalk.bgMagentaBright(
|
|
|
|
|
'@discordjs/voice',
|
2023-04-07 21:39:47 +07:00
|
|
|
)} version ${chalk.redBright('v0.16.0')}`,
|
2022-11-15 20:06:03 +07:00
|
|
|
);
|
2022-06-11 20:13:52 +07:00
|
|
|
}
|
2022-11-15 20:06:03 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
module.exports = async (client, { d: data }, shard) => {
|
|
|
|
|
if (!firstReady) {
|
2023-05-22 19:02:17 +07:00
|
|
|
if (client.options.checkUpdate) {
|
|
|
|
|
client.once('update', (currentVersion, newVersion) => {
|
|
|
|
|
if (!newVersion) {
|
|
|
|
|
console.log(`
|
2022-11-15 20:06:03 +07:00
|
|
|
${chalk.redBright('[WARNING]')} Cannot check new Discord.js-selfbot-v13 version.
|
|
|
|
|
Current: ${chalk.blueBright(currentVersion)}
|
|
|
|
|
|
|
|
|
|
If you don't want to show this message, set ${chalk.cyanBright('checkUpdate')} to false
|
|
|
|
|
|
|
|
|
|
const client = new Client({
|
|
|
|
|
checkUpdate: false,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
and using event update
|
|
|
|
|
https://discordjs-self-v13.netlify.app/#/docs/docs/main/class/Client?scrollTo=e-update\n`);
|
2023-05-22 19:02:17 +07:00
|
|
|
} else if (currentVersion !== newVersion && !currentVersion.includes('-')) {
|
|
|
|
|
console.log(`
|
2022-06-25 10:28:31 +07:00
|
|
|
${chalk.yellowBright('[WARNING]')} New Discord.js-selfbot-v13 version.
|
2022-11-15 20:06:03 +07:00
|
|
|
Current: ${chalk.redBright(currentVersion)} => Latest: ${chalk.greenBright(newVersion)}
|
2022-06-24 09:50:09 +07:00
|
|
|
|
2022-08-21 09:54:13 +07:00
|
|
|
If you don't want to show this message, set ${chalk.cyanBright('checkUpdate')} to false
|
2022-06-24 09:50:09 +07:00
|
|
|
|
2022-11-06 12:05:18 +07:00
|
|
|
const client = new Client({
|
2022-06-24 09:50:09 +07:00
|
|
|
checkUpdate: false,
|
|
|
|
|
});
|
|
|
|
|
|
2022-06-25 10:28:31 +07:00
|
|
|
and using event update
|
2022-08-21 09:54:13 +07:00
|
|
|
https://discordjs-self-v13.netlify.app/#/docs/docs/main/class/Client?scrollTo=e-update\n`);
|
2023-05-22 19:02:17 +07:00
|
|
|
} else {
|
|
|
|
|
console.log(
|
|
|
|
|
`
|
2022-11-15 20:06:03 +07:00
|
|
|
${chalk.greenBright('[OK]')} Discord.js-selfbot-v13 is up to date. Current: ${chalk.blueBright(currentVersion)}
|
2022-06-24 09:50:09 +07:00
|
|
|
|
2022-08-21 09:54:13 +07:00
|
|
|
If you don't want to show this message, set ${chalk.cyanBright('checkUpdate')} to false
|
2022-06-24 09:50:09 +07:00
|
|
|
|
2022-11-06 12:05:18 +07:00
|
|
|
const client = new Client({
|
2022-06-24 09:50:09 +07:00
|
|
|
checkUpdate: false,
|
|
|
|
|
});
|
|
|
|
|
|
2022-06-25 10:28:31 +07:00
|
|
|
and using event update
|
2022-08-21 09:54:13 +07:00
|
|
|
https://discordjs-self-v13.netlify.app/#/docs/docs/main/class/Client?scrollTo=e-update\n`,
|
2023-05-22 19:02:17 +07:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
2022-11-15 20:06:03 +07:00
|
|
|
client.checkUpdate();
|
2022-06-24 09:50:09 +07:00
|
|
|
}
|
2022-03-19 17:37:45 +07:00
|
|
|
|
2022-11-15 20:06:03 +07:00
|
|
|
if (client.options.patchVoice) {
|
|
|
|
|
patchVoice(client);
|
2022-10-14 18:12:47 +07:00
|
|
|
}
|
2022-11-15 20:06:03 +07:00
|
|
|
|
2023-01-26 13:40:51 +07:00
|
|
|
if (client.options.syncStatus) {
|
2022-11-15 20:06:03 +07:00
|
|
|
client.customStatusAuto(client);
|
|
|
|
|
}
|
|
|
|
|
firstReady = true;
|
2022-05-21 20:58:33 +07:00
|
|
|
}
|
|
|
|
|
|
2022-04-16 17:44:43 +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-08-20 20:26:56 +07:00
|
|
|
client.settings._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-10-25 12:37:23 +07:00
|
|
|
client.relationships._setup(data.relationships);
|
|
|
|
|
|
2022-06-06 00:42:08 +07:00
|
|
|
client.user._patchNote(data.notes);
|
2022-04-14 21:32:11 +07:00
|
|
|
|
2022-07-16 16:37:41 +07:00
|
|
|
const syncTime = Date.now();
|
2022-04-16 17:44:43 +07:00
|
|
|
for (const private_channel of data.private_channels) {
|
2022-07-16 16:37:41 +07:00
|
|
|
const channel = client.channels._add(private_channel);
|
|
|
|
|
// Rate limit warning
|
|
|
|
|
if (client.options.DMSync) {
|
|
|
|
|
client.ws.broadcast({
|
|
|
|
|
op: Opcodes.DM_UPDATE,
|
|
|
|
|
d: {
|
|
|
|
|
channel_id: channel.id,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (client.options.DMSync) {
|
|
|
|
|
console.warn(
|
|
|
|
|
`Gateway Rate Limit Warning: Sending ${data.private_channels.length} Requests / ${Date.now() - syncTime || 1} ms`,
|
|
|
|
|
);
|
2022-04-16 17:44:43 +07:00
|
|
|
}
|
2022-06-10 15:51:31 +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
|
|
|
|
2023-06-03 17:21:41 +07:00
|
|
|
for (const gSetting of Array.isArray(data.user_guild_settings) ? data.user_guild_settings : []) {
|
2023-01-08 14:06:42 +07:00
|
|
|
const guild = client.guilds.cache.get(gSetting.guild_id);
|
|
|
|
|
if (guild) guild.settings._patch(gSetting);
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-25 18:54:45 +07:00
|
|
|
const largeGuilds = data.guilds.filter(g => g.large);
|
|
|
|
|
|
2023-01-12 17:35:59 +07:00
|
|
|
client.emit('debug', `[READY] Received ${data.guilds.length} guilds, ${largeGuilds.length} large guilds`);
|
2022-12-25 18:54:45 +07:00
|
|
|
|
2022-06-06 00:42:08 +07:00
|
|
|
// Receive messages in large guilds
|
2022-12-25 18:54:45 +07:00
|
|
|
for (const guild of largeGuilds) {
|
2022-08-21 09:43:22 +07:00
|
|
|
await client.sleep(client.options.messageCreateEventGuildTimeout);
|
2022-05-11 20:19:04 +07:00
|
|
|
client.ws.broadcast({
|
2023-02-16 11:55:35 +07:00
|
|
|
op: Opcodes.GUILD_SUBSCRIPTIONS,
|
2022-05-11 20:19:04 +07:00
|
|
|
d: {
|
|
|
|
|
guild_id: guild.id,
|
|
|
|
|
typing: true,
|
2022-08-09 10:43:16 +07:00
|
|
|
threads: true,
|
2022-05-11 20:19:04 +07:00
|
|
|
activities: true,
|
|
|
|
|
thread_member_lists: [],
|
|
|
|
|
members: [],
|
2022-08-21 09:43:22 +07:00
|
|
|
channels: {},
|
2022-05-11 20:19:04 +07:00
|
|
|
},
|
|
|
|
|
});
|
2022-08-21 09:43:22 +07:00
|
|
|
}
|
2022-05-11 20:19:04 +07:00
|
|
|
|
2022-04-16 17:44:43 +07:00
|
|
|
shard.checkReady();
|
2022-03-19 17:37:45 +07:00
|
|
|
};
|