mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 03:18:17 +00:00
16 lines
604 B
TypeScript
16 lines
604 B
TypeScript
import type { Bot } from "../../bot.ts";
|
|
import { DiscordVoiceRegion } from "../../types/discord.ts";
|
|
import { Collection } from "../../util/collection.ts";
|
|
|
|
/** Returns an array of voice regions that can be used when creating servers. */
|
|
export async function getAvailableVoiceRegions(bot: Bot) {
|
|
const result = await bot.rest.runMethod<DiscordVoiceRegion[]>(bot.rest, "get", bot.constants.endpoints.VOICE_REGIONS());
|
|
|
|
return new Collection(
|
|
result.map((region) => {
|
|
const voiceRegion = bot.transformers.voiceRegion(bot, region);
|
|
return [voiceRegion.id, voiceRegion];
|
|
}),
|
|
);
|
|
}
|