mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-14 10:33:30 +01:00
feat(GuildMemberManager): customisable timeout for _fetchMany (#4081)
This commit is contained in:
@@ -76,6 +76,7 @@ class GuildMemberManager extends BaseManager {
|
|||||||
* @property {?string} query Limit fetch to members with similar usernames
|
* @property {?string} query Limit fetch to members with similar usernames
|
||||||
* @property {number} [limit=0] Maximum number of members to request
|
* @property {number} [limit=0] Maximum number of members to request
|
||||||
* @property {boolean} [withPresences=false] Whether or not to include the presences
|
* @property {boolean} [withPresences=false] Whether or not to include the presences
|
||||||
|
* @property {number} [time=120e3] Timeout for receipt of members
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -223,7 +224,7 @@ class GuildMemberManager extends BaseManager {
|
|||||||
.then(data => this.add(data, cache));
|
.then(data => this.add(data, cache));
|
||||||
}
|
}
|
||||||
|
|
||||||
_fetchMany({ limit = 0, withPresences: presences = false, user: user_ids, query } = {}) {
|
_fetchMany({ limit = 0, withPresences: presences = false, user: user_ids, query, time = 120e3 } = {}) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (this.guild.memberCount === this.cache.size && !query && !limit && !presences && !user_ids) {
|
if (this.guild.memberCount === this.cache.size && !query && !limit && !presences && !user_ids) {
|
||||||
resolve(this.cache);
|
resolve(this.cache);
|
||||||
@@ -262,7 +263,7 @@ class GuildMemberManager extends BaseManager {
|
|||||||
const timeout = this.guild.client.setTimeout(() => {
|
const timeout = this.guild.client.setTimeout(() => {
|
||||||
this.guild.client.removeListener(Events.GUILD_MEMBERS_CHUNK, handler);
|
this.guild.client.removeListener(Events.GUILD_MEMBERS_CHUNK, handler);
|
||||||
reject(new Error('GUILD_MEMBERS_TIMEOUT'));
|
reject(new Error('GUILD_MEMBERS_TIMEOUT'));
|
||||||
}, 120e3);
|
}, time);
|
||||||
this.guild.client.on(Events.GUILD_MEMBERS_CHUNK, handler);
|
this.guild.client.on(Events.GUILD_MEMBERS_CHUNK, handler);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
1
typings/index.d.ts
vendored
1
typings/index.d.ts
vendored
@@ -2381,6 +2381,7 @@ declare module 'discord.js' {
|
|||||||
query?: string;
|
query?: string;
|
||||||
limit?: number;
|
limit?: number;
|
||||||
withPresences?: boolean;
|
withPresences?: boolean;
|
||||||
|
time?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface FileOptions {
|
interface FileOptions {
|
||||||
|
|||||||
Reference in New Issue
Block a user