Documentation ¶
Overview ¶
Package voice handles the Discord voice gateway and UDP connections, as well as managing and keeping track of multiple voice sessions.
This package abstracts the subpackage voice/voicesession and voice/udp.
Index ¶
- Constants
- Variables
- type CloseError
- type Session
- func (s *Session) Disconnect() error
- func (s *Session) DisconnectCtx(ctx context.Context) error
- func (s *Session) JoinChannel(gID discord.GuildID, cID discord.ChannelID, muted, deafened bool) error
- func (s *Session) JoinChannelCtx(ctx context.Context, gID discord.GuildID, cID discord.ChannelID, ...) error
- func (s *Session) Speaking(flag voicegateway.SpeakingFlag) error
- func (s *Session) StopSpeaking() error
- func (s *Session) UpdateServer(ev *gateway.VoiceServerUpdateEvent)
- func (s *Session) UpdateState(ev *gateway.VoiceStateUpdateEvent)
- func (s *Session) Write(b []byte) (int, error)
- func (s *Session) WriteCtx(ctx context.Context, b []byte) (int, error)
- type Voice
Constants ¶
const Protocol = "xsalsa20_poly1305"
Variables ¶
var ( // ErrCannotSend is an error when audio is sent to a closed channel. ErrCannotSend = errors.New("cannot send audio to closed channel") )
var OpusSilence = [...]byte{0xF8, 0xFF, 0xFE}
var WSTimeout = 10 * time.Second
WSTimeout is the duration to wait for a gateway operation including Session to complete before erroring out. This only applies to functions that don't take in a context already.
Functions ¶
This section is empty.
Types ¶
type CloseError ¶ added in v0.7.3
func (*CloseError) Error ¶ added in v0.7.3
func (e *CloseError) Error() string
func (*CloseError) HasError ¶ added in v0.7.3
func (e *CloseError) HasError() bool
type Session ¶
type Session struct { ErrorLog func(err error) // contains filtered or unexported fields }
func (*Session) Disconnect ¶
func (*Session) DisconnectCtx ¶ added in v0.10.0
func (*Session) JoinChannel ¶
func (*Session) JoinChannelCtx ¶ added in v0.10.0
func (*Session) Speaking ¶
func (s *Session) Speaking(flag voicegateway.SpeakingFlag) error
Speaking tells Discord we're speaking. This calls (*voicegateway.Gateway).Speaking().
func (*Session) StopSpeaking ¶
func (*Session) UpdateServer ¶
func (s *Session) UpdateServer(ev *gateway.VoiceServerUpdateEvent)
func (*Session) UpdateState ¶
func (s *Session) UpdateState(ev *gateway.VoiceStateUpdateEvent)
type Voice ¶
type Voice struct { *state.State // ErrorLog will be called when an error occurs (defaults to log.Println) ErrorLog func(err error) // contains filtered or unexported fields }
Voice represents a Voice Repository used for managing voice sessions.
func NewVoice ¶
NewVoice creates a new Voice repository wrapped around a state. The function will also automatically add the GuildVoiceStates intent, as that is required.
func NewVoiceFromToken ¶ added in v0.10.0
NewVoiceFromToken creates a new voice session from the given token.
func (*Voice) GetSession ¶
GetSession gets a session for a guild with a read lock.
func (*Voice) JoinChannel ¶
func (v *Voice) JoinChannel(gID discord.GuildID, cID discord.ChannelID, muted, deafened bool) (*Session, error)
JoinChannel joins the specified channel in the specified guild.
func (*Voice) RemoveSession ¶
RemoveSession removes a session.