mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-17 19:58:18 +00:00
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:
@@ -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,
|
||||
|
||||
@@ -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 },
|
||||
);
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user