Split config/response voice regions, remove APIVoiceRegion alias

This commit is contained in:
Rory&
2026-06-13 01:57:19 +02:00
parent 62c7ba24cd
commit 6995aa7f74
10 changed files with 26 additions and 15 deletions
Binary file not shown.
Binary file not shown.
+1 -1
View File
@@ -256,7 +256,7 @@ async function main() {
process.stdout.write(
"Done in " + yellowBright(elapsed.totalMilliseconds + "." + elapsed.microseconds) + " ms, " + yellowBright(JSON.stringify(part).length) + " bytes (unformatted) ",
);
if (elapsed.totalMilliseconds >= 20) console.log(bgRedBright("\x1b[5m[SLOW]\x1b[25m"));
if (elapsed.totalMilliseconds >= 100) console.log(bgRedBright("\x1b[5m[SLOW]\x1b[25m"));
else console.log();
definitions = { ...definitions, [name]: { ...part } };
+1 -1
View File
@@ -27,7 +27,7 @@ router.get(
route({
responses: {
200: {
body: "APIGuildVoiceRegion",
body: "VoiceRegionListResponse",
},
404: {
body: "APIErrorResponse",
+1 -1
View File
@@ -26,7 +26,7 @@ router.get(
route({
responses: {
200: {
body: "APIGuildVoiceRegion",
body: "VoiceRegionListResponse",
},
},
}),
+2 -2
View File
@@ -19,7 +19,7 @@
import { Guild, Member, VoiceState } from "@spacebar/database";
import { Payload, WebSocket, genVoiceToken } from "@spacebar/gateway";
import { Config, emitEvent, VoiceServerUpdateEvent, VoiceStateUpdateEvent } from "@spacebar/util";
import { Region, VoiceStateUpdateSchema } from "@spacebar/schemas";
import { ConfigVoiceRegion, VoiceStateUpdateSchema } from "@spacebar/schemas";
import { check } from "./instanceOf";
// TODO: check if a voice server is setup
@@ -127,7 +127,7 @@ export async function onVoiceStateUpdate(this: WebSocket, data: Payload) {
where: { id: voiceState.guild_id },
});
const regions = Config.get().regions;
let guildRegion: Region | undefined;
let guildRegion: ConfigVoiceRegion | undefined;
const defaultRegion = regions.available.find((r) => r.id === regions.default);
-1
View File
@@ -56,7 +56,6 @@ export interface APIGuildWithJoinedAt extends GuildCreateResponse {
export type APIRoleArray = Role[];
export type APITemplateArray = Template[];
export type APIGuildVoiceRegion = GuildVoiceRegion[];
export type APILimitsConfiguration = LimitsConfiguration;
export type APIConnectionsConfiguration = Record<
@@ -16,15 +16,27 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
export interface Region {
export interface BaseVoiceRegion {
id: string;
name: string;
endpoint: string;
location?: {
latitude: number;
longitude: number;
};
vip: boolean;
custom: boolean;
deprecated: boolean;
}
export interface ConfigVoiceRegion extends BaseVoiceRegion {
endpoint: string; // not spec, used for config
location?: {
latitude: number;
longitude: number;
}; // not spec, used for config
vip: boolean;
custom: boolean;
deprecated: boolean;
}
export interface VoiceRegionResponse extends BaseVoiceRegion {
optimal: boolean;
}
export type VoiceRegionListResponse = VoiceRegionResponse[];
+1 -1
View File
@@ -18,4 +18,4 @@
export * from "./VoiceIdentifySchema";
export * from "./VoiceVideoSchema";
export * from "./Region";
export * from "./VoiceRegion";
+2 -2
View File
@@ -16,12 +16,12 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { Region } from "@spacebar/schemas";
import { ConfigVoiceRegion } from "@spacebar/schemas";
export class RegionConfiguration {
default: string = "spacebar";
useDefaultAsOptimal: boolean = true;
available: Region[] = [
available: ConfigVoiceRegion[] = [
{
id: "spacebar",
name: "spacebar",