From 6cd75426c6d7da145b40a656e4c1a1d3d26bfb1f Mon Sep 17 00:00:00 2001 From: Vlad Frangu Date: Thu, 8 Apr 2021 14:14:31 +0300 Subject: [PATCH] feat: stage channels! (#107) --- deno/v8/payloads/channel.ts | 8 +++++++- deno/v8/payloads/permissions.ts | 1 + deno/v8/payloads/voice.ts | 4 ++++ deno/v8/rest/guild.ts | 26 ++++++++++++++++++++++++++ deno/v8/rest/mod.ts | 9 +++++++++ package.json | 2 +- v8/payloads/channel.ts | 8 +++++++- v8/payloads/permissions.ts | 1 + v8/payloads/voice.ts | 4 ++++ v8/rest/guild.ts | 26 ++++++++++++++++++++++++++ v8/rest/index.ts | 9 +++++++++ 11 files changed, 95 insertions(+), 3 deletions(-) diff --git a/deno/v8/payloads/channel.ts b/deno/v8/payloads/channel.ts index 337068a25..ea267a971 100644 --- a/deno/v8/payloads/channel.ts +++ b/deno/v8/payloads/channel.ts @@ -114,7 +114,7 @@ export enum ChannelType { /** * A text channel within a guild */ - GUILD_TEXT = 0, + GUILD_TEXT, /** * A direct message between users */ @@ -145,6 +145,12 @@ export enum ChannelType { * See https://discord.com/developers/docs/game-and-server-management/special-channels */ GUILD_STORE, + /** + * A voice channel for hosting events with an audience + * + * See https://support.discord.com/hc/en-us/articles/1500005513722 + */ + GUILD_STAGE_VOICE = 13, } export enum VideoQualityMode { diff --git a/deno/v8/payloads/permissions.ts b/deno/v8/payloads/permissions.ts index 05732a021..7a0517c6f 100644 --- a/deno/v8/payloads/permissions.ts +++ b/deno/v8/payloads/permissions.ts @@ -44,6 +44,7 @@ export const PermissionFlagsBits = { MANAGE_WEBHOOKS: 1n << 29n, MANAGE_EMOJIS: 1n << 30n, USE_APPLICATION_COMMANDS: 1n << 31n, + REQUEST_TO_SPEAK: 1n << 32n, } as const; /** diff --git a/deno/v8/payloads/voice.ts b/deno/v8/payloads/voice.ts index f8837edfb..8c8a15697 100644 --- a/deno/v8/payloads/voice.ts +++ b/deno/v8/payloads/voice.ts @@ -59,6 +59,10 @@ export interface GatewayVoiceState { * Whether this user is muted by the current user */ suppress: boolean; + /** + * The time at which the user requested to speak + */ + request_to_speak_timestamp: string | null; } /** diff --git a/deno/v8/rest/guild.ts b/deno/v8/rest/guild.ts index 9f80c88d6..39bf98a56 100644 --- a/deno/v8/rest/guild.ts +++ b/deno/v8/rest/guild.ts @@ -770,3 +770,29 @@ export interface RESTPatchAPIGuildMemberVerificationJSONBody { } export type RESTPatchAPIGuildMemberVerificationResult = APIGuildMembershipScreening; + +export interface RESTPatchAPIGuildVoiceStateCurrentMemberJSONBody { + /** + * The id of the channel the user is currently in + */ + channel_id: Snowflake; + /** + * Toggles the user's suppress state + */ + suppress?: boolean; + /** + * Sets the user's request to speak + */ + request_to_speak_timestamp?: string | null; +} + +export interface RESTPatchAPIGuildVoiceStateUserJSONBody { + /** + * The id of the channel the user is currently in + */ + channel_id: Snowflake; + /** + * Toggles the user's suppress state + */ + suppress?: boolean; +} diff --git a/deno/v8/rest/mod.ts b/deno/v8/rest/mod.ts index a4059e871..37ad248b3 100644 --- a/deno/v8/rest/mod.ts +++ b/deno/v8/rest/mod.ts @@ -626,6 +626,15 @@ export const Routes = { guildMemberVerification(guildID: Snowflake) { return `/guilds/${guildID}/member-verification` as const; }, + + /** + * Route for: + * - PATCH `/guilds/{guild.id}/voice-states/@me` + * - PATCH `/guilds/{guild.id}/voice-states/{user.id}` + */ + guildVoiceState(guildID: Snowflake, userID: Snowflake | '@me' = '@me') { + return `/guilds/${guildID}/voice-states/${userID}` as const; + }, }; export const RouteBases = { diff --git a/package.json b/package.json index 35ebd9467..80fdc04eb 100644 --- a/package.json +++ b/package.json @@ -90,7 +90,7 @@ } }, "lint-staged": { - "*.{mjs,js,ts}": "eslint --fix --ext mjs,js,ts" + "{v*,default,common}/**/*.{mjs,js,ts}": "eslint --fix --ext mjs,js,ts" }, "commitlint": { "extends": [ diff --git a/v8/payloads/channel.ts b/v8/payloads/channel.ts index e648c66a3..c6ea537eb 100644 --- a/v8/payloads/channel.ts +++ b/v8/payloads/channel.ts @@ -114,7 +114,7 @@ export const enum ChannelType { /** * A text channel within a guild */ - GUILD_TEXT = 0, + GUILD_TEXT, /** * A direct message between users */ @@ -145,6 +145,12 @@ export const enum ChannelType { * See https://discord.com/developers/docs/game-and-server-management/special-channels */ GUILD_STORE, + /** + * A voice channel for hosting events with an audience + * + * See https://support.discord.com/hc/en-us/articles/1500005513722 + */ + GUILD_STAGE_VOICE = 13, } export const enum VideoQualityMode { diff --git a/v8/payloads/permissions.ts b/v8/payloads/permissions.ts index 1313bd196..139740232 100644 --- a/v8/payloads/permissions.ts +++ b/v8/payloads/permissions.ts @@ -44,6 +44,7 @@ export const PermissionFlagsBits = { MANAGE_WEBHOOKS: 1n << 29n, MANAGE_EMOJIS: 1n << 30n, USE_APPLICATION_COMMANDS: 1n << 31n, + REQUEST_TO_SPEAK: 1n << 32n, } as const; /** diff --git a/v8/payloads/voice.ts b/v8/payloads/voice.ts index f98882d83..c65a34678 100644 --- a/v8/payloads/voice.ts +++ b/v8/payloads/voice.ts @@ -59,6 +59,10 @@ export interface GatewayVoiceState { * Whether this user is muted by the current user */ suppress: boolean; + /** + * The time at which the user requested to speak + */ + request_to_speak_timestamp: string | null; } /** diff --git a/v8/rest/guild.ts b/v8/rest/guild.ts index 2f58aa676..f943a68ca 100644 --- a/v8/rest/guild.ts +++ b/v8/rest/guild.ts @@ -770,3 +770,29 @@ export interface RESTPatchAPIGuildMemberVerificationJSONBody { } export type RESTPatchAPIGuildMemberVerificationResult = APIGuildMembershipScreening; + +export interface RESTPatchAPIGuildVoiceStateCurrentMemberJSONBody { + /** + * The id of the channel the user is currently in + */ + channel_id: Snowflake; + /** + * Toggles the user's suppress state + */ + suppress?: boolean; + /** + * Sets the user's request to speak + */ + request_to_speak_timestamp?: string | null; +} + +export interface RESTPatchAPIGuildVoiceStateUserJSONBody { + /** + * The id of the channel the user is currently in + */ + channel_id: Snowflake; + /** + * Toggles the user's suppress state + */ + suppress?: boolean; +} diff --git a/v8/rest/index.ts b/v8/rest/index.ts index 34115e2d3..c7b2efd23 100644 --- a/v8/rest/index.ts +++ b/v8/rest/index.ts @@ -626,6 +626,15 @@ export const Routes = { guildMemberVerification(guildID: Snowflake) { return `/guilds/${guildID}/member-verification` as const; }, + + /** + * Route for: + * - PATCH `/guilds/{guild.id}/voice-states/@me` + * - PATCH `/guilds/{guild.id}/voice-states/{user.id}` + */ + guildVoiceState(guildID: Snowflake, userID: Snowflake | '@me' = '@me') { + return `/guilds/${guildID}/voice-states/${userID}` as const; + }, }; export const RouteBases = {