feat: add support for stage channels (#728)

* feat: add support for stage channels

* idk

* Add helpers for voice state

* Rename updateUserVoiceState() to updateVoiceState()

* Update src/types/channels/channel_types.ts

Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com>

* Update src/helpers/guilds/update_user_voice_state.ts

Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com>

* Update src/helpers/guilds/update_bot_voice_state.ts

Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com>

Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com>
This commit is contained in:
ayntee
2021-04-14 11:11:22 +04:00
committed by GitHub
parent 702896ef8d
commit a854219b81
8 changed files with 91 additions and 0 deletions
@@ -0,0 +1,28 @@
import { RequestManager } from "../../rest/request_manager.ts";
import {
DiscordUpdateSelfVoiceState,
UpdateSelfVoiceState,
} from "../../types/guilds/update_self_voice_state.ts";
import { endpoints } from "../../util/constants.ts";
import { camelKeysToSnakeCase } from "../../util/utils.ts";
/**
* Updates the current user's voice state.
* Caveats:
* - `channel_id` must currently point to a stage channel.
* - current user must already have joined `channel_id`.
* - You must have the `MUTE_MEMBERS` permission to unsuppress yourself. You can always suppress yourself.
* - You must have the `REQUEST_TO_SPEAK` permission to request to speak. You can always clear your own request to speak.
* - You are able to set `request_to_speak_timestamp` to any present or future time.
*/
export function updateBotVoiceState(
guildId: string,
data: UpdateSelfVoiceState,
) {
const payload = camelKeysToSnakeCase<DiscordUpdateSelfVoiceState>(data);
return RequestManager.patch(
endpoints.UPDATE_VOICE_STATE(guildId),
payload,
);
}
@@ -0,0 +1,29 @@
import { RequestManager } from "../../rest/request_manager.ts";
import {
DiscordUpdateOthersVoiceState,
UpdateOthersVoiceState,
} from "../../types/guilds/update_others_voice_state.ts";
import { endpoints } from "../../util/constants.ts";
import { camelKeysToSnakeCase } from "../../util/utils.ts";
/**
* Updates another user's voice state.
* Caveats:
* - `channel_id` must currently point to a stage channel.
* - User must already have joined `channel_id`.
* - You must have the `MUTE_MEMBERS` permission. (Since suppression is the only thing that is available currently.)
* - When unsuppressed, non-bot users will have their `request_to_speak_timestamp` set to the current time. Bot users will not.
* - When suppressed, the user will have their `request_to_speak_timestamp` removed.
*/
export function updateVoiceState(
guildId: string,
userId: string,
data: UpdateOthersVoiceState,
) {
const payload = camelKeysToSnakeCase<DiscordUpdateOthersVoiceState>(data);
return RequestManager.patch(
endpoints.UPDATE_VOICE_STATE(guildId, userId),
payload,
);
}