refactor(core): move setVoiceState to GuildsAPI (#9228)

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
Suneet Tipirneni
2023-03-12 15:37:56 -04:00
committed by GitHub
parent f5ec1cada5
commit dff131e8e4
2 changed files with 17 additions and 15 deletions

View File

@@ -1,5 +1,9 @@
import type { RawFile } from '@discordjs/rest';
import { makeURLSearchParams, type REST } from '@discordjs/rest';
import type {
RESTPatchAPIGuildVoiceStateCurrentMemberJSONBody,
RESTPatchAPIGuildVoiceStateCurrentMemberResult,
} from 'discord-api-types/v10';
import {
Routes,
type GuildMFALevel,
@@ -976,4 +980,17 @@ export class GuildsAPI {
public async getWebhooks(id: Snowflake) {
return this.rest.get(Routes.guildWebhooks(id)) as Promise<RESTGetAPIGuildWebhooksResult>;
}
/**
* Sets the voice state for the current user
*
* @see {@link https://discord.com/developers/docs/resources/guild#modify-current-user-voice-state}
* @param guildId - The id of the guild
* @param options - The options to use when setting the voice state
*/
public async setVoiceState(guildId: Snowflake, options: RESTPatchAPIGuildVoiceStateCurrentMemberJSONBody = {}) {
return this.rest.patch(Routes.guildVoiceState(guildId, '@me'), {
body: options,
}) as Promise<RESTPatchAPIGuildVoiceStateCurrentMemberResult>;
}
}

View File

@@ -12,8 +12,6 @@ import {
type RESTPatchAPICurrentUserResult,
type RESTPatchAPIGuildMemberJSONBody,
type RESTPatchAPIGuildMemberResult,
type RESTPatchAPIGuildVoiceStateCurrentMemberJSONBody,
type RESTPatchAPIGuildVoiceStateCurrentMemberResult,
type RESTPostAPICurrentUserCreateDMChannelResult,
type RESTPutAPICurrentUserApplicationRoleConnectionJSONBody,
type RESTPutAPICurrentUserApplicationRoleConnectionResult,
@@ -99,19 +97,6 @@ export class UsersAPI {
}) as Promise<RESTPatchAPIGuildMemberResult>;
}
/**
* Sets the voice state for the current user
*
* @see {@link https://discord.com/developers/docs/resources/guild#modify-current-user-voice-state}
* @param guildId - The id of the guild
* @param options - The options to use when setting the voice state
*/
public async setVoiceState(guildId: Snowflake, options: RESTPatchAPIGuildVoiceStateCurrentMemberJSONBody = {}) {
return this.rest.patch(Routes.guildVoiceState(guildId, '@me'), {
body: options,
}) as Promise<RESTPatchAPIGuildVoiceStateCurrentMemberResult>;
}
/**
* Opens a new DM channel with a user
*