From be4b647490b31afc2556326fb45752423eeab046 Mon Sep 17 00:00:00 2001 From: imnaiyar Date: Mon, 12 Aug 2024 10:49:55 -0500 Subject: [PATCH 1/8] feat(VoiceState): add methods for fetching voice state --- packages/core/src/api/guild.ts | 6 +- packages/core/src/api/voice.ts | 66 ++++++++++++++++++- .../src/managers/VoiceStateManager.js | 22 +++++++ .../discord.js/src/structures/VoiceState.js | 9 +++ packages/discord.js/typings/index.d.ts | 2 + packages/discord.js/typings/rawDataTypes.d.ts | 3 +- 6 files changed, 104 insertions(+), 4 deletions(-) diff --git a/packages/core/src/api/guild.ts b/packages/core/src/api/guild.ts index 697db33abcc4..f6be5fc1ff24 100644 --- a/packages/core/src/api/guild.ts +++ b/packages/core/src/api/guild.ts @@ -687,11 +687,12 @@ export class GuildsAPI { /** * Edits a user's voice state in a guild * - * @see {@link https://discord.com/developers/docs/resources/guild#modify-user-voice-state} + * @see {@link https://discord.com/developers/docs/resources/user#modify-user-voice-state} * @param guildId - The id of the guild to edit the current user's voice state in * @param userId - The id of the user to edit the voice state for * @param body - The data for editing the voice state * @param options - The options for editing the voice state + * @deprecated Use {@link VoiceAPI#editUserVoiceState} instead */ public async editUserVoiceState( guildId: Snowflake, @@ -1298,9 +1299,10 @@ export class GuildsAPI { /** * Sets the voice state for the current user * - * @see {@link https://discord.com/developers/docs/resources/guild#modify-current-user-voice-state} + * @see {@link https://discord.com/developers/docs/resources/voice#modify-current-user-voice-state} * @param guildId - The id of the guild * @param body - The options for setting the voice state + * @deprecated Use {@link VoiceAPI#setVoiceState} */ public async setVoiceState(guildId: Snowflake, body: RESTPatchAPIGuildVoiceStateCurrentMemberJSONBody = {}) { return this.rest.patch(Routes.guildVoiceState(guildId, '@me'), { diff --git a/packages/core/src/api/voice.ts b/packages/core/src/api/voice.ts index a1ff6869bd51..33d3c2d7980c 100644 --- a/packages/core/src/api/voice.ts +++ b/packages/core/src/api/voice.ts @@ -1,7 +1,16 @@ /* eslint-disable jsdoc/check-param-names */ import type { RequestData, REST } from '@discordjs/rest'; -import { Routes, type RESTGetAPIVoiceRegionsResult } from 'discord-api-types/v10'; +import { + Routes, + type Snowflake, + type RESTGetAPIVoiceRegionsResult, + type RESTGetAPIGuildVoiceStateUserResult, + type RESTGetAPIGuildVoiceStateCurrentMemberResult, + type RESTPatchAPIGuildVoiceStateUserJSONBody, + type RESTPatchAPIGuildVoiceStateCurrentMemberResult, + type RESTPatchAPIGuildVoiceStateCurrentMemberJSONBody, +} from 'discord-api-types/v10'; export class VoiceAPI { public constructor(private readonly rest: REST) {} @@ -15,4 +24,59 @@ export class VoiceAPI { public async getVoiceRegions({ signal }: Pick = {}) { return this.rest.get(Routes.voiceRegions(), { signal }) as Promise; } + + /** + * Fetches voice state of a user by their id + * + * @see {@link https://discord.com/developers/docs/resources/voice#get-user-voice-state} + * @param options - The options for fetching user voice state + */ + public async getUserVoiceState(guildId: Snowflake, userId: Snowflake, { signal }: Pick = {}) { + return this.rest.get(Routes.guildVoiceState(guildId, userId), { + signal, + }) as Promise; + } + + /** + * Fetches the current user's voice state + * + * @see {@link https://discord.com/developers/docs/resources/voice#get-current-user-voice-state} + * @param options - The options for fetching user voice state + */ + public async getVoiceState(guildId: Snowflake, { signal }: Pick = {}) { + return this.rest.get(Routes.guildVoiceState(guildId, '@me'), { + signal, + }) as Promise; + } + + /** + * Edits a user's voice state in a guild + * + * @see {@link https://discord.com/developers/docs/resources/user#modify-user-voice-state} + * @param guildId - The id of the guild to edit the current user's voice state in + * @param userId - The id of the user to edit the voice state for + * @param body - The data for editing the voice state + * @param options - The options for editing the voice state + */ + public async editUserVoiceState( + guildId: Snowflake, + userId: Snowflake, + body: RESTPatchAPIGuildVoiceStateUserJSONBody, + { reason, signal }: Pick = {}, + ) { + await this.rest.patch(Routes.guildVoiceState(guildId, userId), { reason, body, signal }); + } + + /** + * Sets the voice state for the current user + * + * @see {@link https://discord.com/developers/docs/resources/voice#modify-current-user-voice-state} + * @param guildId - The id of the guild + * @param body - The options for setting the voice state + */ + public async setVoiceState(guildId: Snowflake, body: RESTPatchAPIGuildVoiceStateCurrentMemberJSONBody = {}) { + return this.rest.patch(Routes.guildVoiceState(guildId, '@me'), { + body, + }) as Promise; + } } diff --git a/packages/discord.js/src/managers/VoiceStateManager.js b/packages/discord.js/src/managers/VoiceStateManager.js index c42fdd2c36e7..764662b7e2c6 100644 --- a/packages/discord.js/src/managers/VoiceStateManager.js +++ b/packages/discord.js/src/managers/VoiceStateManager.js @@ -1,5 +1,6 @@ 'use strict'; +const { Routes } = require('discord-api-types/v10'); const CachedManager = require('./CachedManager'); const VoiceState = require('../structures/VoiceState'); @@ -32,6 +33,27 @@ class VoiceStateManager extends CachedManager { if (cache) this.cache.set(data.user_id, entry); return entry; } + + /** + * Obtains a user's voice state from discord or from the cache if it's already available. + * @param {GuildMemberResolvable} member The member whose voice state is to be fetched + * @param {BaseFetchOptions} [options] Additional options for this fetch + * @returns {Promise} + * @example + * // Fetch a member's voice state + * guild.voiceStates.fetch("851588007697580033") + * .then(state => console.log(`Member's voice channel: ${state.channel}`)) + * .catch(console.error); + */ + async fetch(member, { cache = true, force = false } = {}) { + const id = this.guild.members.resolveId(member); + if (!force) { + const existing = this.cache.get(id); + if (existing) return existing; + } + const data = await this.client.rest.get(Routes.guildVoiceState(this.guild.id, id)); + return this._add(data, cache); + } } module.exports = VoiceStateManager; diff --git a/packages/discord.js/src/structures/VoiceState.js b/packages/discord.js/src/structures/VoiceState.js index 8f379c5a7c2d..861fd4968462 100644 --- a/packages/discord.js/src/structures/VoiceState.js +++ b/packages/discord.js/src/structures/VoiceState.js @@ -250,6 +250,15 @@ class VoiceState extends Base { return this; } + /** + * Fetches this voice state. + * @param {boolean} [force=true] Whether to skip the cache check and request the API + * @returns {Promise} + */ + fetch(force = true) { + return this.guild.voiceStates.fetch(this.member, { force }); + } + /** * Toggles the request to speak in the channel. * Only applicable for stage channels and for the client's own voice state. diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index b1071e1d3558..9dd73388d03b 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -3589,6 +3589,7 @@ export class VoiceState extends Base { public setRequestToSpeak(request?: boolean): Promise; public setSuppressed(suppressed?: boolean): Promise; public edit(options: VoiceStateEditOptions): Promise; + public fetch(force?: boolean): Promise; } // tslint:disable-next-line no-empty-interface @@ -4591,6 +4592,7 @@ export class UserManager extends CachedManager export class VoiceStateManager extends CachedManager { private constructor(guild: Guild, iterable?: Iterable); public guild: Guild; + public fetch(member: GuildMemberResolvable, options?: BaseFetchOptions): Promise; } //#endregion diff --git a/packages/discord.js/typings/rawDataTypes.d.ts b/packages/discord.js/typings/rawDataTypes.d.ts index bb54ad696f80..eb52e789b50f 100644 --- a/packages/discord.js/typings/rawDataTypes.d.ts +++ b/packages/discord.js/typings/rawDataTypes.d.ts @@ -47,6 +47,7 @@ import { APIUnavailableGuild, APIUser, APIVoiceRegion, + APIVoiceState, APIWebhook, GatewayActivity, GatewayActivityAssets, @@ -194,7 +195,7 @@ export type RawUserData = export type RawVoiceRegionData = APIVoiceRegion; -export type RawVoiceStateData = GatewayVoiceState | Omit; +export type RawVoiceStateData = APIVoiceState | Omit; export type RawWebhookData = | APIWebhook From 4ba518e1b5637514a9e5116c5217485543acba36 Mon Sep 17 00:00:00 2001 From: imnaiyar Date: Mon, 12 Aug 2024 11:05:19 -0500 Subject: [PATCH 2/8] fix: links to new methods --- packages/core/src/api/guild.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/core/src/api/guild.ts b/packages/core/src/api/guild.ts index f6be5fc1ff24..08dedc5203d5 100644 --- a/packages/core/src/api/guild.ts +++ b/packages/core/src/api/guild.ts @@ -102,6 +102,7 @@ import { type RESTPutAPIGuildTemplateSyncResult, type Snowflake, } from 'discord-api-types/v10'; +import { VoiceAPI } from './voice'; export class GuildsAPI { public constructor(private readonly rest: REST) {} @@ -692,7 +693,7 @@ export class GuildsAPI { * @param userId - The id of the user to edit the voice state for * @param body - The data for editing the voice state * @param options - The options for editing the voice state - * @deprecated Use {@link VoiceAPI#editUserVoiceState} instead + * @deprecated Use {@link VoiceAPI.editUserVoiceState} instead */ public async editUserVoiceState( guildId: Snowflake, @@ -1302,7 +1303,7 @@ export class GuildsAPI { * @see {@link https://discord.com/developers/docs/resources/voice#modify-current-user-voice-state} * @param guildId - The id of the guild * @param body - The options for setting the voice state - * @deprecated Use {@link VoiceAPI#setVoiceState} + * @deprecated Use {@link VoiceAPI.setVoiceState} */ public async setVoiceState(guildId: Snowflake, body: RESTPatchAPIGuildVoiceStateCurrentMemberJSONBody = {}) { return this.rest.patch(Routes.guildVoiceState(guildId, '@me'), { From d30e72168fe719fa1c88f6587d90b23b5c018d52 Mon Sep 17 00:00:00 2001 From: imnaiyar Date: Mon, 12 Aug 2024 11:51:00 -0500 Subject: [PATCH 3/8] chore: remove unused import --- packages/discord.js/typings/rawDataTypes.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/discord.js/typings/rawDataTypes.d.ts b/packages/discord.js/typings/rawDataTypes.d.ts index eb52e789b50f..f2c906eb09fe 100644 --- a/packages/discord.js/typings/rawDataTypes.d.ts +++ b/packages/discord.js/typings/rawDataTypes.d.ts @@ -63,7 +63,6 @@ import { GatewayPresenceUpdate, GatewayReadyDispatchData, GatewayTypingStartDispatchData, - GatewayVoiceState, RESTAPIPartialCurrentUserGuild, RESTGetAPIWebhookWithTokenResult, RESTPatchAPIChannelMessageJSONBody, From dce1444e3d1afc3b58e4cde8aa5b7c0595f84655 Mon Sep 17 00:00:00 2001 From: imnaiyar Date: Mon, 12 Aug 2024 12:47:06 -0500 Subject: [PATCH 4/8] chore: use member id --- packages/discord.js/src/structures/VoiceState.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/discord.js/src/structures/VoiceState.js b/packages/discord.js/src/structures/VoiceState.js index 861fd4968462..890681e53a0e 100644 --- a/packages/discord.js/src/structures/VoiceState.js +++ b/packages/discord.js/src/structures/VoiceState.js @@ -256,7 +256,7 @@ class VoiceState extends Base { * @returns {Promise} */ fetch(force = true) { - return this.guild.voiceStates.fetch(this.member, { force }); + return this.guild.voiceStates.fetch(this.id, { force }); } /** From 96cd73d8cbaab721f3a37b10349008e1f21f0169 Mon Sep 17 00:00:00 2001 From: imnaiyar Date: Mon, 12 Aug 2024 15:04:29 -0500 Subject: [PATCH 5/8] chore: requested changes --- packages/core/src/api/guild.ts | 2 +- packages/core/src/api/voice.ts | 14 ++++++++++---- .../discord.js/src/managers/VoiceStateManager.js | 4 ++-- packages/discord.js/typings/index.d.ts | 2 +- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/packages/core/src/api/guild.ts b/packages/core/src/api/guild.ts index 08dedc5203d5..ac2f93ee3371 100644 --- a/packages/core/src/api/guild.ts +++ b/packages/core/src/api/guild.ts @@ -1303,7 +1303,7 @@ export class GuildsAPI { * @see {@link https://discord.com/developers/docs/resources/voice#modify-current-user-voice-state} * @param guildId - The id of the guild * @param body - The options for setting the voice state - * @deprecated Use {@link VoiceAPI.setVoiceState} + * @deprecated Use {@link VoiceAPI.editVoiceState} instead */ public async setVoiceState(guildId: Snowflake, body: RESTPatchAPIGuildVoiceStateCurrentMemberJSONBody = {}) { return this.rest.patch(Routes.guildVoiceState(guildId, '@me'), { diff --git a/packages/core/src/api/voice.ts b/packages/core/src/api/voice.ts index 33d3c2d7980c..88d1a2ea514b 100644 --- a/packages/core/src/api/voice.ts +++ b/packages/core/src/api/voice.ts @@ -52,7 +52,7 @@ export class VoiceAPI { /** * Edits a user's voice state in a guild * - * @see {@link https://discord.com/developers/docs/resources/user#modify-user-voice-state} + * @see {@link https://discord.com/developers/docs/resources/voice#modify-user-voice-state} * @param guildId - The id of the guild to edit the current user's voice state in * @param userId - The id of the user to edit the voice state for * @param body - The data for editing the voice state @@ -68,15 +68,21 @@ export class VoiceAPI { } /** - * Sets the voice state for the current user + * Edits the voice state for the current user * * @see {@link https://discord.com/developers/docs/resources/voice#modify-current-user-voice-state} * @param guildId - The id of the guild - * @param body - The options for setting the voice state + * @param body - The data for editing the voice state + * @param options - The options for editing the voice state */ - public async setVoiceState(guildId: Snowflake, body: RESTPatchAPIGuildVoiceStateCurrentMemberJSONBody = {}) { + public async editVoiceState( + guildId: Snowflake, + body: RESTPatchAPIGuildVoiceStateCurrentMemberJSONBody = {}, + { signal }: Pick = {}, + ) { return this.rest.patch(Routes.guildVoiceState(guildId, '@me'), { body, + signal, }) as Promise; } } diff --git a/packages/discord.js/src/managers/VoiceStateManager.js b/packages/discord.js/src/managers/VoiceStateManager.js index 764662b7e2c6..f1e6d5679f76 100644 --- a/packages/discord.js/src/managers/VoiceStateManager.js +++ b/packages/discord.js/src/managers/VoiceStateManager.js @@ -41,8 +41,8 @@ class VoiceStateManager extends CachedManager { * @returns {Promise} * @example * // Fetch a member's voice state - * guild.voiceStates.fetch("851588007697580033") - * .then(state => console.log(`Member's voice channel: ${state.channel}`)) + * guild.voiceStates.fetch("66564597481480192") + * .then(console.log) * .catch(console.error); */ async fetch(member, { cache = true, force = false } = {}) { diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index 9dd73388d03b..df0fba053268 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -3589,7 +3589,7 @@ export class VoiceState extends Base { public setRequestToSpeak(request?: boolean): Promise; public setSuppressed(suppressed?: boolean): Promise; public edit(options: VoiceStateEditOptions): Promise; - public fetch(force?: boolean): Promise; + public fetch(force?: boolean): Promise; } // tslint:disable-next-line no-empty-interface From 2cf57112295de5623f00c10ab2dbf7daf72bcad8 Mon Sep 17 00:00:00 2001 From: imnaiyar Date: Tue, 13 Aug 2024 04:45:53 -0500 Subject: [PATCH 6/8] chore: '@me' as fetch param --- packages/core/src/api/guild.ts | 2 +- packages/discord.js/src/managers/VoiceStateManager.js | 6 +++--- packages/discord.js/typings/index.d.ts | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/core/src/api/guild.ts b/packages/core/src/api/guild.ts index ac2f93ee3371..943d18e40326 100644 --- a/packages/core/src/api/guild.ts +++ b/packages/core/src/api/guild.ts @@ -688,7 +688,7 @@ export class GuildsAPI { /** * Edits a user's voice state in a guild * - * @see {@link https://discord.com/developers/docs/resources/user#modify-user-voice-state} + * @see {@link https://discord.com/developers/docs/resources/voice#modify-user-voice-state} * @param guildId - The id of the guild to edit the current user's voice state in * @param userId - The id of the user to edit the voice state for * @param body - The data for editing the voice state diff --git a/packages/discord.js/src/managers/VoiceStateManager.js b/packages/discord.js/src/managers/VoiceStateManager.js index f1e6d5679f76..586bd5ad9e08 100644 --- a/packages/discord.js/src/managers/VoiceStateManager.js +++ b/packages/discord.js/src/managers/VoiceStateManager.js @@ -36,7 +36,7 @@ class VoiceStateManager extends CachedManager { /** * Obtains a user's voice state from discord or from the cache if it's already available. - * @param {GuildMemberResolvable} member The member whose voice state is to be fetched + * @param {GuildMemberResolvable|'@me'} member The member whose voice state is to be fetched * @param {BaseFetchOptions} [options] Additional options for this fetch * @returns {Promise} * @example @@ -46,9 +46,9 @@ class VoiceStateManager extends CachedManager { * .catch(console.error); */ async fetch(member, { cache = true, force = false } = {}) { - const id = this.guild.members.resolveId(member); + const id = member === '@me' ? member : this.guild.members.resolveId(member); if (!force) { - const existing = this.cache.get(id); + const existing = this.cache.get(id === '@me' ? this.client.user.id : id); if (existing) return existing; } const data = await this.client.rest.get(Routes.guildVoiceState(this.guild.id, id)); diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index df0fba053268..f431139bcd3b 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -4592,7 +4592,7 @@ export class UserManager extends CachedManager export class VoiceStateManager extends CachedManager { private constructor(guild: Guild, iterable?: Iterable); public guild: Guild; - public fetch(member: GuildMemberResolvable, options?: BaseFetchOptions): Promise; + public fetch(member: GuildMemberResolvable | '@me', options?: BaseFetchOptions): Promise; } //#endregion From 1b6216f56eb7bee06e5ace51130f8ee735fd0b71 Mon Sep 17 00:00:00 2001 From: imnaiyar <137700126+imnaiyar@users.noreply.github.com> Date: Mon, 19 Aug 2024 02:42:26 -0500 Subject: [PATCH 7/8] chore: add ediUserVoiceState return type --- packages/core/src/api/guild.ts | 7 ++++++- packages/core/src/api/voice.ts | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/core/src/api/guild.ts b/packages/core/src/api/guild.ts index 943d18e40326..1d53ba129110 100644 --- a/packages/core/src/api/guild.ts +++ b/packages/core/src/api/guild.ts @@ -69,6 +69,7 @@ import { type RESTPatchAPIGuildVoiceStateCurrentMemberJSONBody, type RESTPatchAPIGuildVoiceStateCurrentMemberResult, type RESTPatchAPIGuildVoiceStateUserJSONBody, + type RESTPatchAPIGuildVoiceStateUserResult, type RESTPatchAPIGuildWelcomeScreenJSONBody, type RESTPatchAPIGuildWelcomeScreenResult, type RESTPatchAPIGuildWidgetSettingsJSONBody, @@ -701,7 +702,11 @@ export class GuildsAPI { body: RESTPatchAPIGuildVoiceStateUserJSONBody, { reason, signal }: Pick = {}, ) { - await this.rest.patch(Routes.guildVoiceState(guildId, userId), { reason, body, signal }); + return this.rest.patch(Routes.guildVoiceState(guildId, userId), { + reason, + body, + signal, + }) as Promise; } /** diff --git a/packages/core/src/api/voice.ts b/packages/core/src/api/voice.ts index 88d1a2ea514b..d58e8069a90f 100644 --- a/packages/core/src/api/voice.ts +++ b/packages/core/src/api/voice.ts @@ -10,6 +10,7 @@ import { type RESTPatchAPIGuildVoiceStateUserJSONBody, type RESTPatchAPIGuildVoiceStateCurrentMemberResult, type RESTPatchAPIGuildVoiceStateCurrentMemberJSONBody, + type RESTPatchAPIGuildVoiceStateUserResult, } from 'discord-api-types/v10'; export class VoiceAPI { @@ -64,7 +65,11 @@ export class VoiceAPI { body: RESTPatchAPIGuildVoiceStateUserJSONBody, { reason, signal }: Pick = {}, ) { - await this.rest.patch(Routes.guildVoiceState(guildId, userId), { reason, body, signal }); + return this.rest.patch(Routes.guildVoiceState(guildId, userId), { + reason, + body, + signal, + }) as Promise; } /** From 12396aeedcf041874744052e8cbae0aa7e0f8171 Mon Sep 17 00:00:00 2001 From: imnaiyar <137700126+imnaiyar@users.noreply.github.com> Date: Tue, 20 Aug 2024 04:24:09 -0500 Subject: [PATCH 8/8] refactor: redirect function calls to VoiceAPI --- packages/core/src/api/guild.ts | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/packages/core/src/api/guild.ts b/packages/core/src/api/guild.ts index 1d53ba129110..1963b4b7a153 100644 --- a/packages/core/src/api/guild.ts +++ b/packages/core/src/api/guild.ts @@ -67,9 +67,7 @@ import { type RESTPatchAPIGuildTemplateJSONBody, type RESTPatchAPIGuildTemplateResult, type RESTPatchAPIGuildVoiceStateCurrentMemberJSONBody, - type RESTPatchAPIGuildVoiceStateCurrentMemberResult, type RESTPatchAPIGuildVoiceStateUserJSONBody, - type RESTPatchAPIGuildVoiceStateUserResult, type RESTPatchAPIGuildWelcomeScreenJSONBody, type RESTPatchAPIGuildWelcomeScreenResult, type RESTPatchAPIGuildWidgetSettingsJSONBody, @@ -702,11 +700,7 @@ export class GuildsAPI { body: RESTPatchAPIGuildVoiceStateUserJSONBody, { reason, signal }: Pick = {}, ) { - return this.rest.patch(Routes.guildVoiceState(guildId, userId), { - reason, - body, - signal, - }) as Promise; + return new VoiceAPI(this.rest).editUserVoiceState(guildId, userId, body, { reason, signal }); } /** @@ -1307,13 +1301,16 @@ export class GuildsAPI { * * @see {@link https://discord.com/developers/docs/resources/voice#modify-current-user-voice-state} * @param guildId - The id of the guild - * @param body - The options for setting the voice state + * @param body - The data for setting the voice state + * @param options - The options for setting the voice state * @deprecated Use {@link VoiceAPI.editVoiceState} instead */ - public async setVoiceState(guildId: Snowflake, body: RESTPatchAPIGuildVoiceStateCurrentMemberJSONBody = {}) { - return this.rest.patch(Routes.guildVoiceState(guildId, '@me'), { - body, - }) as Promise; + public async setVoiceState( + guildId: Snowflake, + body: RESTPatchAPIGuildVoiceStateCurrentMemberJSONBody = {}, + { signal }: Pick = {}, + ) { + return new VoiceAPI(this.rest).editVoiceState(guildId, body, { signal }); } /**