Skip to content

Commit a7196dc

Browse files
authored
fix: backport only passing relevant options to API when fetching (#11230)
* fix: only pass relevant options to API when fetching * chore: update changes
1 parent a036618 commit a7196dc

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

packages/discord.js/src/managers/GuildBanManager.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,12 @@ class GuildBanManager extends CachedManager {
120120
return this._add(data, cache);
121121
}
122122

123-
async _fetchMany(options = {}) {
123+
async _fetchMany({ cache, ...apiOptions } = {}) {
124124
const data = await this.client.rest.get(Routes.guildBans(this.guild.id), {
125-
query: makeURLSearchParams(options),
125+
query: makeURLSearchParams(apiOptions),
126126
});
127127

128-
return data.reduce((col, ban) => col.set(ban.user.id, this._add(ban, options.cache)), new Collection());
128+
return data.reduce((col, ban) => col.set(ban.user.id, this._add(ban, cache)), new Collection());
129129
}
130130

131131
/**

packages/discord.js/src/managers/MessageManager.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,12 @@ class MessageManager extends CachedManager {
111111
return this._add(data, cache);
112112
}
113113

114-
async _fetchMany(options = {}) {
114+
async _fetchMany({ cache, ...apiOptions } = {}) {
115115
const data = await this.client.rest.get(Routes.channelMessages(this.channel.id), {
116-
query: makeURLSearchParams(options),
116+
query: makeURLSearchParams(apiOptions),
117117
});
118118

119-
return data.reduce((_data, message) => _data.set(message.id, this._add(message, options.cache)), new Collection());
119+
return data.reduce((_data, message) => _data.set(message.id, this._add(message, cache)), new Collection());
120120
}
121121

122122
/**
@@ -158,11 +158,11 @@ class MessageManager extends CachedManager {
158158
* .then(messages => console.log(`Received ${messages.items.length} messages`))
159159
* .catch(console.error);
160160
*/
161-
async fetchPins(options = {}) {
161+
async fetchPins({ cache, ...apiOptions } = {}) {
162162
const data = await this.client.rest.get(Routes.channelMessagesPins(this.channel.id), {
163163
query: makeURLSearchParams({
164-
...options,
165-
before: options.before && new Date(options.before).toISOString(),
164+
...apiOptions,
165+
before: apiOptions.before && new Date(apiOptions.before).toISOString(),
166166
}),
167167
});
168168

@@ -172,7 +172,7 @@ class MessageManager extends CachedManager {
172172
get pinnedAt() {
173173
return new Date(this.pinnedTimestamp);
174174
},
175-
message: this._add(item.message, options.cache),
175+
message: this._add(item.message, cache),
176176
})),
177177
hasMore: data.has_more,
178178
};

0 commit comments

Comments
 (0)