mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 11:28:15 +00:00
add: addToCache option
This commit is contained in:
@@ -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
|
* 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.
|
* 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)) {
|
if (!(ws.identifyPayload.intents && DiscordGatewayIntents.GUILD_MEMBERS)) {
|
||||||
throw new Error(Errors.MISSING_INTENT_GUILD_MEMBERS);
|
throw new Error(Errors.MISSING_INTENT_GUILD_MEMBERS);
|
||||||
}
|
}
|
||||||
@@ -61,11 +64,13 @@ export async function getMembers(guildId: string, options?: ListGuildMembers) {
|
|||||||
guildId,
|
guildId,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (options?.addToCache !== false) {
|
||||||
await cacheHandlers.set(
|
await cacheHandlers.set(
|
||||||
"members",
|
"members",
|
||||||
discordenoMember.id,
|
discordenoMember.id,
|
||||||
discordenoMember,
|
discordenoMember,
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return discordenoMember;
|
return discordenoMember;
|
||||||
}),
|
}),
|
||||||
|
|||||||
Reference in New Issue
Block a user