refactor: remove RequestManager and use runMethod() (#732)

* fix(rest/process_request): use DiscordHTTPResponseCodes

* refactor: remove RequestManager

* refactor: remove RequestManager and use runMethod()
This commit is contained in:
ayntee
2021-04-02 23:18:51 +04:00
committed by GitHub
parent ec9ceaab04
commit 5f1b82a4e8
106 changed files with 418 additions and 326 deletions
+2 -2
View File
@@ -1,4 +1,4 @@
import { RequestManager } from "../../rest/request_manager.ts";
import { rest } from "../../rest/rest.ts";
import { endpoints } from "../../util/constants.ts";
import { requireBotGuildPermissions } from "../../util/permissions.ts";
import { urlToBase64 } from "../../util/utils.ts";
@@ -16,7 +16,7 @@ export async function createEmoji(
image = await urlToBase64(image);
}
const result = await RequestManager.post(endpoints.GUILD_EMOJIS(guildId), {
const result = await rest.runMethod("post", endpoints.GUILD_EMOJIS(guildId), {
...options,
name,
image,
+3 -2
View File
@@ -1,4 +1,4 @@
import { RequestManager } from "../../rest/request_manager.ts";
import { rest } from "../../rest/rest.ts";
import { endpoints } from "../../util/constants.ts";
import { requireBotGuildPermissions } from "../../util/permissions.ts";
@@ -10,7 +10,8 @@ export async function deleteEmoji(
) {
await requireBotGuildPermissions(guildId, ["MANAGE_EMOJIS"]);
const result = await RequestManager.delete(
const result = await rest.runMethod(
"delete",
endpoints.GUILD_EMOJI(guildId, id),
{ reason },
);
+3 -2
View File
@@ -1,4 +1,4 @@
import { RequestManager } from "../../rest/request_manager.ts";
import { rest } from "../../rest/rest.ts";
import { endpoints } from "../../util/constants.ts";
import { requireBotGuildPermissions } from "../../util/permissions.ts";
@@ -10,7 +10,8 @@ export async function editEmoji(
) {
await requireBotGuildPermissions(guildId, ["MANAGE_EMOJIS"]);
const result = await RequestManager.patch(
const result = await rest.runMethod(
"patch",
endpoints.GUILD_EMOJI(guildId, id),
{
name: options.name,
+4 -2
View File
@@ -1,5 +1,6 @@
import { cacheHandlers } from "../../cache.ts";
import { RequestManager } from "../../rest/request_manager.ts";
import { rest } from "../../rest/rest.ts";
import { Errors } from "../../types/misc/errors.ts";
import { endpoints } from "../../util/constants.ts";
/**
@@ -12,7 +13,8 @@ export async function getEmoji(
emojiId: string,
addToCache = true,
) {
const result = (await RequestManager.get(
const result = (await rest.runMethod(
"get",
endpoints.GUILD_EMOJI(guildId, emojiId),
)) as Emoji;
+4 -4
View File
@@ -1,5 +1,6 @@
import { cacheHandlers } from "../../cache.ts";
import { RequestManager } from "../../rest/request_manager.ts";
import { rest } from "../../rest/rest.ts";
import { Errors } from "../../types/misc/errors.ts";
import { endpoints } from "../../util/constants.ts";
/**
@@ -8,9 +9,8 @@ import { endpoints } from "../../util/constants.ts";
* ⚠️ **If you need this, you are probably doing something wrong. Always use cache.guilds.get()?.emojis
*/
export async function getEmojis(guildId: string, addToCache = true) {
const result = (await RequestManager.get(
endpoints.GUILD_EMOJIS(guildId),
)) as Emoji[];
const result =
(await rest.runMethod("get", endpoints.GUILD_EMOJIS(guildId))) as Emoji[];
if (addToCache) {
const guild = await cacheHandlers.get("guilds", guildId);