add: addToCache option

This commit is contained in:
ITOH
2021-04-30 15:04:44 +02:00
parent b28ab09f7e
commit 7aab8a8030
+11 -6
View File
@@ -19,7 +19,10 @@ import { ws } from "../../ws/ws.ts";
* REST(this function): 50/s global(across all shards) rate limit with ALL requests this included
* GW(fetchMembers): 120/m(PER shard) rate limit. Meaning if you have 8 shards your limit is 960/m.
*/
export async function getMembers(guildId: string, options?: ListGuildMembers) {
export async function getMembers(
guildId: string,
options?: ListGuildMembers & { addToCache?: boolean },
) {
if (!(ws.identifyPayload.intents && DiscordGatewayIntents.GUILD_MEMBERS)) {
throw new Error(Errors.MISSING_INTENT_GUILD_MEMBERS);
}
@@ -61,11 +64,13 @@ export async function getMembers(guildId: string, options?: ListGuildMembers) {
guildId,
);
await cacheHandlers.set(
"members",
discordenoMember.id,
discordenoMember,
);
if (options?.addToCache !== false) {
await cacheHandlers.set(
"members",
discordenoMember.id,
discordenoMember,
);
}
return discordenoMember;
}),