fix: only pass relevant options to API when fetching (#11228)

* fix: only pass relevant options to API when fetching

* chore: requested changes

* fix: missed instance
This commit is contained in:
Danial Raza
2025-10-31 21:48:51 +01:00
committed by GitHub
parent d06d8c0806
commit f26a5ed869
2 changed files with 10 additions and 10 deletions

View File

@@ -124,12 +124,12 @@ class GuildBanManager extends CachedManager {
return this._add(data, cache); return this._add(data, cache);
} }
async _fetchMany(options = {}) { async _fetchMany({ cache, ...apiOptions } = {}) {
const data = await this.client.rest.get(Routes.guildBans(this.guild.id), { const data = await this.client.rest.get(Routes.guildBans(this.guild.id), {
query: makeURLSearchParams(options), query: makeURLSearchParams(apiOptions),
}); });
return data.reduce((col, ban) => col.set(ban.user.id, this._add(ban, options.cache)), new Collection()); return data.reduce((col, ban) => col.set(ban.user.id, this._add(ban, cache)), new Collection());
} }
/** /**

View File

@@ -115,12 +115,12 @@ class MessageManager extends CachedManager {
return this._add(data, cache); return this._add(data, cache);
} }
async _fetchMany(options = {}) { async _fetchMany({ cache, ...apiOptions } = {}) {
const data = await this.client.rest.get(Routes.channelMessages(this.channel.id), { const data = await this.client.rest.get(Routes.channelMessages(this.channel.id), {
query: makeURLSearchParams(options), query: makeURLSearchParams(apiOptions),
}); });
return data.reduce((_data, message) => _data.set(message.id, this._add(message, options.cache)), new Collection()); return data.reduce((_data, message) => _data.set(message.id, this._add(message, cache)), new Collection());
} }
/** /**
@@ -162,11 +162,11 @@ class MessageManager extends CachedManager {
* .then(messages => console.log(`Received ${messages.items.length} messages`)) * .then(messages => console.log(`Received ${messages.items.length} messages`))
* .catch(console.error); * .catch(console.error);
*/ */
async fetchPins(options = {}) { async fetchPins({ cache, ...apiOptions } = {}) {
const data = await this.client.rest.get(Routes.channelMessagesPins(this.channel.id), { const data = await this.client.rest.get(Routes.channelMessagesPins(this.channel.id), {
query: makeURLSearchParams({ query: makeURLSearchParams({
...options, ...apiOptions,
before: options.before && new Date(options.before).toISOString(), before: apiOptions.before && new Date(apiOptions.before).toISOString(),
}), }),
}); });
@@ -176,7 +176,7 @@ class MessageManager extends CachedManager {
get pinnedAt() { get pinnedAt() {
return new Date(this.pinnedTimestamp); return new Date(this.pinnedTimestamp);
}, },
message: this._add(item.message, options.cache), message: this._add(item.message, cache),
})), })),
hasMore: data.has_more, hasMore: data.has_more,
}; };