func (c *Client) SwitchVoiceChannel(ctx context.Context, guildID string, channelID string) error {
	c.mu.Lock()
	defer c.mu.Unlock()
	conn, ok := c.voiceConnections[guildID]
	if !ok {
		return discord.ErrNotConnectedToVoice
	}
	vsu := &voice.StateUpdate{
		State: voice.State{
			GuildID:   guildID,
			ChannelID: &channelID,
			SelfMute:  conn.State().SelfMute,
			SelfDeaf:  conn.State().SelfDeaf,
		},
	}
	if err := c.sendPayload(ctx, gatewayOpcodeVoiceStateUpdate, vsu); err != nil {
		return err
	}
	return nil
}
SwitchVoiceChannel can be used to switch from a voice channel to another. It requires an
active voice connection in the guild. You can get one with JoinVoiceChannel.
package harmony
import (
	"context"
	"encoding/json"
	"errors"
	"fmt"
	"time"
	"github.com/skwair/harmony/discord"
	"github.com/skwair/harmony/internal/payload"
	"github.com/skwair/harmony/voice"
)
func (c *Client) JoinVoiceChannel(ctx context.Context, guildID, channelID string, mute, deaf bool) (*voice.Connection, error) {
	c.mu.Lock()
	defer c.mu.Unlock()
	if !c.isConnected() {
		return nil, discord.ErrGatewayNotConnected
	}
	if _, ok := c.voiceConnections[guildID]; ok {
		return nil, discord.ErrAlreadyConnectedToVoice
	}
	c.connectingToVoice.Store(true)
	defer c.connectingToVoice.Store(false)
	vsu := &voice.StateUpdate{
		State: voice.State{
			GuildID:   guildID,
			ChannelID: &channelID,
			SelfMute:  mute,
			SelfDeaf:  deaf,
		},
	}
	if err := c.sendPayload(ctx, gatewayOpcodeVoiceStateUpdate, vsu); err != nil {
		return nil, err
	}
	state, server, err := getStateAndServer(c.voicePayloads)
	if err != nil {
		return nil, err
	}
	conn, err := voice.Connect(ctx, state, server, voice.WithLogger(c.logger))
	if err != nil {
		return nil, err
	}
	c.voiceConnections[guildID] = conn
	return conn, nil
}