From f6f435bb1f0ed89640c4f5d105c1d9fc249bb30f Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Sat, 23 Jan 2021 20:17:11 +0100 Subject: [PATCH] feat(handlers): add getAvailableVoiceRegions() (#425) * add voice endpoint * feat(handlers): add getVoiceRegions * Update mod.ts * remove breaking changes --- src/api/handlers/guild.ts | 5 +++++ src/api/handlers/mod.ts | 2 ++ src/util/constants.ts | 3 +++ 3 files changed, 10 insertions(+) diff --git a/src/api/handlers/guild.ts b/src/api/handlers/guild.ts index b70e532ab..f290d4dc1 100644 --- a/src/api/handlers/guild.ts +++ b/src/api/handlers/guild.ts @@ -729,6 +729,11 @@ export function leaveGuild(guildID: string) { return RequestManager.delete(endpoints.GUILD_LEAVE(guildID)); } +/** Returns an array of voice regions that can be used when creating servers. */ +export function getAvailableVoiceRegions() { + return RequestManager.get(endpoints.VOICE_REGIONS); +} + /** 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 function getVoiceRegions(guildID: string) { return RequestManager.get(endpoints.GUILD_REGIONS(guildID)); diff --git a/src/api/handlers/mod.ts b/src/api/handlers/mod.ts index c76b4227c..9d10d70f9 100644 --- a/src/api/handlers/mod.ts +++ b/src/api/handlers/mod.ts @@ -40,6 +40,7 @@ import { emojiURL, fetchMembers, getAuditLogs, + getAvailableVoiceRegions, getBan, getBans, getChannel, @@ -171,6 +172,7 @@ export let handlers = { getGuildPreview, getGuildTemplate, getGuildTemplates, + getAvailableVoiceRegions, getIntegrations, getInvites, getMember, diff --git a/src/util/constants.ts b/src/util/constants.ts index bde99b4a8..03674cb29 100644 --- a/src/util/constants.ts +++ b/src/util/constants.ts @@ -117,6 +117,9 @@ export const endpoints = { GUILD_TEMPLATES: (guildID: string) => `${GUILDS_BASE(guildID)}/templates`, GUILD_PREVIEW: (guildID: string) => `${GUILDS_BASE(guildID)}/preview`, + // Voice + VOICE_REGIONS: `${baseEndpoints.BASE_URL}/voice/regions`, + INVITE: (inviteCode: string) => `${baseEndpoints.BASE_URL}/invites/${inviteCode}`,