fir more things

This commit is contained in:
ITOH
2021-04-07 10:27:44 +02:00
parent 941ebd3beb
commit 313e7d2d35
16 changed files with 74 additions and 38 deletions
+15 -2
View File
@@ -1,9 +1,22 @@
import { rest } from "../../rest/rest.ts";
import {
DiscordVoiceRegion,
VoiceRegion,
} from "../../types/voice/voice_region.ts";
import { Collection } from "../../util/collection.ts";
import { endpoints } from "../../util/constants.ts";
import { snakeKeysToCamelCase } from "../../util/utils.ts";
/** Returns a list of voice region objects for the guild. Unlike the similar /voice route, this returns VIP servers when the guild is VIP-enabled. */
export async function getVoiceRegions(guildId: string) {
const result = await rest.runMethod("get", endpoints.GUILD_REGIONS(guildId));
const result = await rest.runMethod(
"get",
endpoints.GUILD_REGIONS(guildId),
) as DiscordVoiceRegion[];
return result;
const convertedRegions = snakeKeysToCamelCase<VoiceRegion[]>(result);
return new Collection<string, VoiceRegion>(
convertedRegions.map((region) => [region.id, region]),
);
}