fix: intents checking bugs

This commit is contained in:
Skillz4Killz
2021-06-17 18:03:32 +00:00
committed by GitHub
parent a584b81b12
commit 21449fec64
2 changed files with 4 additions and 2 deletions
+2 -1
View File
@@ -17,7 +17,8 @@ import { ws } from "../../ws/ws.ts";
*/ */
export function fetchMembers(guildId: bigint, shardId: number, options?: Omit<RequestGuildMembers, "guildId">) { export function fetchMembers(guildId: bigint, shardId: number, options?: Omit<RequestGuildMembers, "guildId">) {
// You can request 1 member without the intent // You can request 1 member without the intent
if ((!options?.limit || options.limit > 1) && !(ws.identifyPayload.intents & DiscordGatewayIntents.GuildMembers)) { // Check if intents is not 0 as proxy ws won't set intents in other instances
if (ws.identifyPayload.intents && (!options?.limit || options.limit > 1) && !(ws.identifyPayload.intents & DiscordGatewayIntents.GuildMembers)) {
throw new Error(Errors.MISSING_INTENT_GUILD_MEMBERS); throw new Error(Errors.MISSING_INTENT_GUILD_MEMBERS);
} }
+2 -1
View File
@@ -21,7 +21,8 @@ import { ws } from "../../ws/ws.ts";
* 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: bigint, options?: ListGuildMembers & { addToCache?: boolean }) { export async function getMembers(guildId: bigint, options?: ListGuildMembers & { addToCache?: boolean }) {
if (!(ws.identifyPayload.intents && DiscordGatewayIntents.GuildMembers)) { // Check if intents is not 0 as proxy ws won't set intents in other instances
if (ws.identifyPayload.intents && !(ws.identifyPayload.intents & DiscordGatewayIntents.GuildMembers)) {
throw new Error(Errors.MISSING_INTENT_GUILD_MEMBERS); throw new Error(Errors.MISSING_INTENT_GUILD_MEMBERS);
} }