feat(ClientOptions): Add messageCreateEventGuildTimeout`

Increase timeout each time WS send

If you don't want a timeout, set it to `0`

Co-Authored-By: Nguyễn Hồng Đức <hongducyb123@gmail.com>
This commit is contained in:
March 7th
2022-08-21 09:43:22 +07:00
parent 9f33ab1cfd
commit 1587b12d22
6 changed files with 13 additions and 9 deletions

View File

@@ -918,6 +918,9 @@ class Client extends BaseClient {
if (typeof options.waitGuildTimeout !== 'number' || isNaN(options.waitGuildTimeout)) {
throw new TypeError('CLIENT_INVALID_OPTION', 'waitGuildTimeout', 'a number');
}
if (typeof options.messageCreateEventGuildTimeout !== 'number' || isNaN(options.messageCreateEventGuildTimeout)) {
throw new TypeError('CLIENT_INVALID_OPTION', 'messageCreateEventGuildTimeout', 'a number');
}
if (typeof options.restWsBridgeTimeout !== 'number' || isNaN(options.restWsBridgeTimeout)) {
throw new TypeError('CLIENT_INVALID_OPTION', 'restWsBridgeTimeout', 'a number');
}

View File

@@ -59,7 +59,7 @@ async function checkUpdate(client) {
return client.emit('update', Discord.version, latest_tag);
}
module.exports = (client, { d: data }, shard) => {
module.exports = async (client, { d: data }, shard) => {
checkUpdate(client);
if (client.options.patchVoice && !running) {
@@ -146,7 +146,8 @@ module.exports = (client, { d: data }, shard) => {
}
// Receive messages in large guilds
client.guilds.cache.map(guild => {
for (const guild of data.guilds) {
await client.sleep(client.options.messageCreateEventGuildTimeout);
client.ws.broadcast({
op: Opcodes.LAZY_REQUEST,
d: {
@@ -156,13 +157,10 @@ module.exports = (client, { d: data }, shard) => {
activities: true,
thread_member_lists: [],
members: [],
channels: {
// [guild.channels.cache.first().id]: [[0, 99]],
},
channels: {},
},
});
return true;
});
}
client.relationships._setup(data.relationships);