fix: backport only passing relevant options to API when fetching (#11230)

* fix: only pass relevant options to API when fetching

* chore: update changes
This commit is contained in:
Naiyar
2025-11-01 03:35:51 +06:00
committed by GitHub
parent a03661844f
commit a7196dc969
2 changed files with 10 additions and 10 deletions

View File

@@ -120,12 +120,12 @@ class GuildBanManager extends CachedManager {
return this._add(data, cache);
}
async _fetchMany(options = {}) {
async _fetchMany({ cache, ...apiOptions } = {}) {
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

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