Merge pull request #412 from NekoCyan/main

fix & docs: description.
This commit is contained in:
Elysia 2022-11-23 23:52:08 +07:00 committed by GitHub
commit 942ad0714c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 8 deletions

View File

@ -68,16 +68,15 @@ all examples shown use the "overlap" method
```js ```js
const guild = client.guilds.cache.get('id'); const guild = client.guilds.cache.get('id');
const channel = guild.channels.cache.get('id'); const channel = guild.channels.cache.get('id');
const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
// Overlap (slow) // Overlap (slow)
for (let index = 0; index <= guild.memberCount; index += 100) { for (let index = 0; index <= guild.memberCount; index += 100) {
await guild.members.fetchMemberList(channel, index, index !== 100).catch(() => {}); await guild.members.fetchMemberList(channel, index, index !== 100).catch(() => {});
await delay(500); await client.sleep(500);
} }
// Non-overlap (fast) // Non-overlap (fast)
for (let index = 0; index <= guild.memberCount; index += 200) { for (let index = 0; index <= guild.memberCount; index += 200) {
await guild.members.fetchMemberList(channel, index == 0 ? 100 : index, index !== 100).catch(() => {}); await guild.members.fetchMemberList(channel, index == 0 ? 100 : index, index !== 100).catch(() => {});
await delay(500); await client.sleep(500);
} }
console.log(guild.members.cache.size); // will print the number of members in the guild console.log(guild.members.cache.size); // will print the number of members in the guild
``` ```

View File

@ -484,7 +484,7 @@ class GuildMemberManager extends CachedManager {
} }
/** /**
* Fetches multiple members from the guild. * Fetches multiple members from the guild in the channel.
* @param {GuildTextChannelResolvable} channel The channel to get members from (Members has VIEW_CHANNEL permission) * @param {GuildTextChannelResolvable} channel The channel to get members from (Members has VIEW_CHANNEL permission)
* @param {number} [offset=0] Start index of the members to get * @param {number} [offset=0] Start index of the members to get
* @param {boolean} [double=false] Whether to use double range * @param {boolean} [double=false] Whether to use double range
@ -495,16 +495,15 @@ class GuildMemberManager extends CachedManager {
* @example * @example
* const guild = client.guilds.cache.get('id'); * const guild = client.guilds.cache.get('id');
* const channel = guild.channels.cache.get('id'); * const channel = guild.channels.cache.get('id');
* const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
* // Overlap (slow) * // Overlap (slow)
* for (let index = 0; index <= guild.memberCount; index += 100) { * for (let index = 0; index <= guild.memberCount; index += 100) {
* await guild.members.fetchMemberList(channel, index, index !== 100).catch(() => {}); * await guild.members.fetchMemberList(channel, index, index !== 100).catch(() => {});
* await delay(500); * await client.sleep(500);
* } * }
* // Non-overlap (fast) * // Non-overlap (fast)
* for (let index = 0; index <= guild.memberCount; index += 200) { * for (let index = 0; index <= guild.memberCount; index += 200) {
* await guild.members.fetchMemberList(channel, index == 0 ? 100 : index, index !== 100).catch(() => {}); * await guild.members.fetchMemberList(channel, index == 0 ? 100 : index, index !== 100).catch(() => {});
* await delay(500); * await client.sleep(500);
* } * }
* console.log(guild.members.cache.size); // will print the number of members in the guild * console.log(guild.members.cache.size); // will print the number of members in the guild
*/ */
@ -532,7 +531,6 @@ class GuildMemberManager extends CachedManager {
if (guild.id !== this.guild.id) return; if (guild.id !== this.guild.id) return;
if (type == 'INVALIDATE' && offset > 100) { if (type == 'INVALIDATE' && offset > 100) {
if (retry < retryMax) { if (retry < retryMax) {
console.log('Retrying...');
this.guild.shard.send({ this.guild.shard.send({
op: Opcodes.LAZY_REQUEST, op: Opcodes.LAZY_REQUEST,
d: { d: {