From 47df256c57064e49c040c7bdae54eba1f7db24ad Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Sun, 18 Apr 2021 20:40:57 +0200 Subject: [PATCH] Create get_discovery_categories.ts --- .../discovery/get_discovery_categories.ts | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/helpers/discovery/get_discovery_categories.ts diff --git a/src/helpers/discovery/get_discovery_categories.ts b/src/helpers/discovery/get_discovery_categories.ts new file mode 100644 index 000000000..fab403a14 --- /dev/null +++ b/src/helpers/discovery/get_discovery_categories.ts @@ -0,0 +1,25 @@ +import { rest } from "../../rest/rest.ts"; +import { + DiscordDiscoveryCategory, + DiscoveryCategory, +} from "../../types/discovery/discovery_category.ts"; +import { Collection } from "../../util/collection.ts"; +import { endpoints } from "../../util/constants.ts"; +import { snakeKeysToCamelCase } from "../../util/utils.ts"; + +/** Returns an array of discovery category objects that can be used when editing guilds */ +export async function getDiscoveryCategories() { + const result = await rest.runMethod( + "get", + endpoints.DISCOVERY_CATEGORIES, + ); + + return new Collection( + result.map( + (category) => [ + category.id, + snakeKeysToCamelCase(category), + ] + ), + ); +}