Merge branch 'main' into remove-raw-avatar-url

This commit is contained in:
Skillz4Killz
2021-04-03 23:38:34 -04:00
committed by GitHub
95 changed files with 319 additions and 228 deletions
+1
View File
@@ -1,4 +1,5 @@
import { rest } from "../../rest/rest.ts";
import { Errors } from "../../types/misc/errors.ts";
import { endpoints } from "../../util/constants.ts";
import { urlToBase64 } from "../../util/utils.ts";
+1
View File
@@ -1,6 +1,7 @@
import { cacheHandlers } from "../../cache.ts";
import { rest } from "../../rest/rest.ts";
import { structures } from "../../structures/mod.ts";
import { Errors } from "../../types/misc/errors.ts";
import { endpoints } from "../../util/constants.ts";
import {
requireBotChannelPermissions,
+5 -1
View File
@@ -1,7 +1,11 @@
import { identifyPayload } from "../../bot.ts";
import { Member } from "../../structures/mod.ts";
import { DiscordGatewayIntents } from "../../types/gateway/gateway_intents.ts";
import { Errors } from "../../types/misc/errors.ts";
import { Collection } from "../../util/collection.ts";
import { requestAllMembers } from "../../ws/shard_manager.ts";
import { DiscordGatewayIntents } from "../../types/gateway/gateway_intents.ts";
import { Errors } from "../../types/misc/errors.ts";
/**
* ⚠️ BEGINNER DEVS!! YOU SHOULD ALMOST NEVER NEED THIS AND YOU CAN GET FROM cache.members.get()
@@ -19,7 +23,7 @@ export function fetchMembers(
// You can request 1 member without the intent
if (
(!options?.limit || options.limit > 1) &&
!(identifyPayload.intents && Intents.GUILD_MEMBERS)
!(identifyPayload.intents && DiscordGatewayIntents.GUILD_MEMBERS)
) {
throw new Error(Errors.MISSING_INTENT_GUILD_MEMBERS);
}
+5 -4
View File
@@ -1,5 +1,4 @@
import { cacheHandlers } from "../../cache.ts";
import { RequestManager } from "../../rest/request_manager.ts";
import { rest } from "../../rest/rest.ts";
import { structures } from "../../structures/mod.ts";
import { endpoints } from "../../util/constants.ts";
@@ -16,9 +15,11 @@ export async function getMember(
const guild = await cacheHandlers.get("guilds", guildId);
if (!guild && !options?.force) return;
const data = (await rest.runMethod("get",
endpoints.GUILD_MEMBER(guildId, id),
)) as MemberCreatePayload;
const data =
(await rest.runMethod(
"get",
endpoints.GUILD_MEMBER(guildId, id),
)) as MemberCreatePayload;
const memberStruct = await structures.createMemberStruct(data, guildId);
await cacheHandlers.set("members", memberStruct.id, memberStruct);
+10 -14
View File
@@ -2,6 +2,9 @@ import { identifyPayload } from "../../bot.ts";
import { cacheHandlers } from "../../cache.ts";
import { rest } from "../../rest/rest.ts";
import { Member, structures } from "../../structures/mod.ts";
import { DiscordGatewayIntents } from "../../types/gateway/gateway_intents.ts";
import { DiscordGuildMember } from "../../types/guilds/guild_member.ts";
import { Errors } from "../../types/misc/errors.ts";
import { Collection } from "../../util/collection.ts";
import { endpoints } from "../../util/constants.ts";
@@ -14,7 +17,7 @@ import { endpoints } from "../../util/constants.ts";
* 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?: GetMemberOptions) {
if (!(identifyPayload.intents && Intents.GUILD_MEMBERS)) {
if (!(identifyPayload.intents && DiscordGatewayIntents.GUILD_MEMBERS)) {
throw new Error(Errors.MISSING_INTENT_GUILD_MEMBERS);
}
@@ -39,19 +42,12 @@ export async function getMembers(guildId: string, options?: GetMemberOptions) {
);
}
const result =
(await rest.runMethod(
"get",
`${endpoints.GUILD_MEMBERS(guildId)}?limit=${
membersLeft > 1000
? 1000
: membersLeft
}${
options?.after
? `&after=${options.after}`
: ""
}`,
)) as MemberCreatePayload[];
const result = (await rest.runMethod(
"get",
`${endpoints.GUILD_MEMBERS(guildId)}?limit=${
membersLeft > 1000 ? 1000 : membersLeft
}${options?.after ? `&after=${options.after}` : ""}`,
)) as DiscordGuildMember[];
const memberStructures = await Promise.all(
result.map(async (member) => {
+1
View File
@@ -1,5 +1,6 @@
import { botId } from "../../bot.ts";
import { rest } from "../../rest/rest.ts";
import { Errors } from "../../types/misc/errors.ts";
import { endpoints } from "../../util/constants.ts";
import {
highestRole,
+1
View File
@@ -1,4 +1,5 @@
import { rest } from "../../rest/rest.ts";
import { Errors } from "../../types/misc/errors.ts";
import { endpoints } from "../../util/constants.ts";
import { requireBotGuildPermissions } from "../../util/permissions.ts";
import { camelKeysToSnakeCase } from "../../util/utils.ts";