integrations

This commit is contained in:
ITOH
2021-04-24 19:38:16 +02:00
parent 933a5c70eb
commit 0c02b94143
3 changed files with 7 additions and 16 deletions
+4 -10
View File
@@ -1,22 +1,16 @@
import { rest } from "../../rest/rest.ts";
import {
DiscordVoiceRegion,
VoiceRegion,
} from "../../types/voice/voice_region.ts";
import { 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(
const result = await rest.runMethod<VoiceRegion[]>(
"get",
endpoints.GUILD_REGIONS(guildId),
) as DiscordVoiceRegion[];
const convertedRegions = snakeKeysToCamelCase<VoiceRegion[]>(result);
);
return new Collection<string, VoiceRegion>(
convertedRegions.map((region) => [region.id, region]),
result.map((region) => [region.id, region]),
);
}