Skip to content

Commit

Permalink
refactor(core): move setVoiceState to GuildsAPI (#9228)
Browse files Browse the repository at this point in the history
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
suneettipirneni and kodiakhq[bot] committed Mar 12, 2023
1 parent f5ec1ca commit dff131e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
17 changes: 17 additions & 0 deletions packages/core/src/api/guild.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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>;
}
}
15 changes: 0 additions & 15 deletions packages/core/src/api/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import {
type RESTPatchAPICurrentUserResult,
type RESTPatchAPIGuildMemberJSONBody,
type RESTPatchAPIGuildMemberResult,
type RESTPatchAPIGuildVoiceStateCurrentMemberJSONBody,
type RESTPatchAPIGuildVoiceStateCurrentMemberResult,
type RESTPostAPICurrentUserCreateDMChannelResult,
type RESTPutAPICurrentUserApplicationRoleConnectionJSONBody,
type RESTPutAPICurrentUserApplicationRoleConnectionResult,
Expand Down Expand Up @@ -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
*
Expand Down

2 comments on commit dff131e

@vercel
Copy link

@vercel vercel bot commented on dff131e Mar 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on dff131e Mar 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.