Skip to content

Commit

Permalink
feat(GuildMemberManager): customisable timeout for _fetchMany (discor…
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinbioj authored Apr 16, 2020
1 parent 4625881 commit ff3454e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/managers/GuildMemberManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class GuildMemberManager extends BaseManager {
* @property {?string} query Limit fetch to members with similar usernames
* @property {number} [limit=0] Maximum number of members to request
* @property {boolean} [withPresences=false] Whether or not to include the presences
* @property {number} [time=120e3] Timeout for receipt of members
*/

/**
Expand Down Expand Up @@ -223,7 +224,7 @@ class GuildMemberManager extends BaseManager {
.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) => {
if (this.guild.memberCount === this.cache.size && !query && !limit && !presences && !user_ids) {
resolve(this.cache);
Expand Down Expand Up @@ -262,7 +263,7 @@ class GuildMemberManager extends BaseManager {
const timeout = this.guild.client.setTimeout(() => {
this.guild.client.removeListener(Events.GUILD_MEMBERS_CHUNK, handler);
reject(new Error('GUILD_MEMBERS_TIMEOUT'));
}, 120e3);
}, time);
this.guild.client.on(Events.GUILD_MEMBERS_CHUNK, handler);
});
}
Expand Down
1 change: 1 addition & 0 deletions typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2381,6 +2381,7 @@ declare module 'discord.js' {
query?: string;
limit?: number;
withPresences?: boolean;
time?: number;
}

interface FileOptions {
Expand Down

0 comments on commit ff3454e

Please sign in to comment.