voice

package
v0.14.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 27, 2019 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AudioPacket

type AudioPacket struct {
	Type      uint8
	Version   uint8
	Sequence  uint16
	Timestamp uint32
	SSRC      uint32
	Opus      []byte
}

AudioPacket is a parsed and decrypted RTP frame containing Opus encoded audio.

type Connection

type Connection struct {

	// Send is used to send Opus encoded audio packets.
	Send chan []byte
	// Recv is used to receive audio packets
	// containing Opus encoded audio data.
	Recv chan *AudioPacket
	// contains filtered or unexported fields
}

Connection represents a Discord voice connection.

func EstablishNewConnection

func EstablishNewConnection(ctx context.Context, state *StateUpdate, server *ServerUpdate, opts ...ConnectionOption) (*Connection, error)

EstablishNewConnection establishes a new voice connection with the provided information. This connection should be closed by calling its Close method when no longer needed.

func (*Connection) Close

func (vc *Connection) Close()

Disconnect closes the voice connection.

func (*Connection) Logger

func (vc *Connection) Logger() log.Logger

Logger is here to make the logger available to third party packages that need to report errors related to this voice connection.

func (*Connection) Speaking

func (vc *Connection) Speaking(ctx context.Context, s bool) error

Speaking sends an Opcode 5 Speaking payload. This does nothing if the user is already in the given state.

type ConnectionOption

type ConnectionOption func(*Connection)

ConnectionOption is a function that configures a Connection. It is used in EstablishNewConnection.

func WithLogger

func WithLogger(l log.Logger) ConnectionOption

WithLogger can be used to set the logger used by this connection. Defaults to a standard logger reporting only errors. See the log package for more information about logging with Harmony.

type ServerUpdate

type ServerUpdate struct {
	Token    string `json:"token"`
	GuildID  string `json:"guild_id"`
	Endpoint string `json:"endpoint"`
}

ServerUpdate is the payload describing the update of a voice server.

type State

type State struct {
	GuildID    string  `json:"guild_id"`
	ChannelID  *string `json:"channel_id"`
	UserID     string  `json:"user_id"`
	SessionID  string  `json:"session_id"`
	Deaf       bool    `json:"deaf"`
	Mute       bool    `json:"mute"`
	SelfDeaf   bool    `json:"self_deaf"`
	SelfMute   bool    `json:"self_mute"`
	SelfStream bool    `json:"self_stream"`
	Suppress   bool    `json:"suppress"` // Whether this user is muted by the current user.
}

State represents the voice state of a user.

func (*State) Clone

func (v *State) Clone() *State

Clone returns a clone of this StateUpdate.

type StateUpdate

type StateUpdate struct {
	State
}

StateUpdate is the payload describing the update of the voice state of a user.

Directories

Path Synopsis
Package voiceutil provides utilities to work with harmony voice connections.
Package voiceutil provides utilities to work with harmony voice connections.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL