fix: ClientUser.notes return empty Collection
fix: Recieve messages from large servers #72
feat: checkUpdate return Debug event (not console.log)
feat: RelationshipAdd event, param type return RelationshipTypes
feat: online status when login
feat: fix documents
This commit is contained in:
March 7th
2022-06-06 00:42:08 +07:00
parent 04251a8b87
commit c165824419
10 changed files with 78 additions and 51 deletions

View File

@@ -1,6 +1,24 @@
'use strict';
const { Events, Status } = require('../../../util/Constants');
const { Events, Opcodes, Status } = require('../../../util/Constants');
// Receive messages in large guilds
const run = (client, guild) => {
client.ws.broadcast({
op: Opcodes.LAZY_REQUEST,
d: {
guild_id: guild.id,
typing: true,
threads: false,
activities: true,
thread_member_lists: [],
members: [],
channels: {
// [guild.channels.cache.first().id]: [[0, 99]],
},
},
});
};
module.exports = (client, { d: data }, shard) => {
let guild = client.guilds.cache.get(data.id);
@@ -8,6 +26,7 @@ module.exports = (client, { d: data }, shard) => {
if (!guild.available && !data.unavailable) {
// A newly available guild
guild._patch(data);
run(client, guild);
}
} else {
// A new guild
@@ -20,6 +39,7 @@ module.exports = (client, { d: data }, shard) => {
* @param {Guild} guild The created guild
*/
client.emit(Events.GUILD_CREATE, guild);
run(client, guild);
}
}
};

View File

@@ -8,30 +8,31 @@ const Discord = require('../../../index');
const { Events, Opcodes } = require('../../../util/Constants');
const { Networking } = require('../../../util/Voice');
async function checkUpdate() {
async function checkUpdate(client) {
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 client.emit(
Events.DEBUG,
`${chalk.yellowBright('[WARNING]')} New Discord.js-selfbot-v13 version.
Old Version: ${chalk.redBright(Discord.version)} => New Version: ${chalk.greenBright(lastest_tag)}`,
);
}
/*
Removed:
console.log(
client.emit(
Events.DEBUG,
`${chalk.greenBright('[OK]')} Discord.js-selfbot-v13 is up to date. Version: ${chalk.blueBright(Discord.version)}`,
);
*/
return null;
}
module.exports = (client, { d: data }, shard) => {
if (client.options.checkUpdate) {
try {
checkUpdate();
checkUpdate(client);
} catch (e) {
console.log(`${chalk.redBright('[Fail]')} Check Update error:`, e.message);
client.emit(Events.DEBUG, `${chalk.redBright('[Fail]')} Check Update error: ${e.message}`);
}
}
@@ -82,9 +83,7 @@ module.exports = (client, { d: data }, shard) => {
client.user.connectedAccounts = data.connected_accounts ?? [];
for (const [userid, note] of Object.entries(data.notes ?? {})) {
client.user.notes.set(userid, note);
}
client.user._patchNote(data.notes);
for (const private_channel of data.private_channels) {
client.channels._add(private_channel);
@@ -118,7 +117,7 @@ module.exports = (client, { d: data }, shard) => {
client.guilds._add(guild);
}
// Receive messages in large guilds [Test]
// Receive messages in large guilds
client.guilds.cache.map(guild => {
client.ws.broadcast({
op: Opcodes.LAZY_REQUEST,

View File

@@ -1,6 +1,6 @@
'use strict';
const { Events } = require('../../../util/Constants');
const { Events, Relationship } = require('../../../util/Constants');
module.exports = (client, { d: data }) => {
if (data.user) {
@@ -11,7 +11,7 @@ module.exports = (client, { d: data }) => {
* Emitted whenever a relationship is updated.
* @event Client#relationshipAdd
* @param {UserId} user The userID that was updated
* @param {Number} type The new relationship type
* @param {RelationshipType} type The new relationship type
*/
client.emit(Events.RELATIONSHIP_ADD, data.id, data.type);
client.emit(Events.RELATIONSHIP_ADD, data.id, Relationship[data.type]);
};