mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 03:18:17 +00:00
23 lines
895 B
TypeScript
23 lines
895 B
TypeScript
import type { UpdateVoiceState } from "../../types/voice/updateVoiceState.ts";
|
|
import type { AtLeastOne } from "../../types/util.ts";
|
|
import type { Bot } from "../../bot.ts";
|
|
import { GatewayOpcodes } from "../../types/codes/gatewayOpcodes.ts";
|
|
|
|
/** Connect or join a voice channel inside a guild. By default, the "selfDeaf" option is true. Requires `CONNECT` and `VIEW_CHANNEL` permissions. */
|
|
export async function connectToVoiceChannel(
|
|
bot: Bot,
|
|
guildId: bigint,
|
|
channelId: bigint,
|
|
options?: AtLeastOne<Omit<UpdateVoiceState, "guildId" | "channelId">>,
|
|
) {
|
|
bot.gateway.sendShardMessage(bot.gateway, bot.utils.calculateShardId(bot.gateway, guildId), {
|
|
op: GatewayOpcodes.VoiceStateUpdate,
|
|
d: {
|
|
guild_id: guildId.toString(),
|
|
channel_id: channelId.toString(),
|
|
self_mute: Boolean(options?.selfMute),
|
|
self_deaf: options?.selfDeaf ?? true,
|
|
},
|
|
});
|
|
}
|