Back to godoc.org
eaglesong.dev/dvoice

Package dvoice

v0.0.0-...-770ecc0
Latest Go to latest

The highest tagged major version is .

Published: Jul 18, 2020 | License: MIT | Module: eaglesong.dev/dvoice

Index

Variables

var (
	ErrConnClosed   = errors.New("voice connection is closed")
	ErrStateTimeout = errors.New("timed out waiting for voice state")
)

Predefined errors

func Convert

func Convert(ctx context.Context, frames chan<- []byte, r io.Reader, bitrate int) error

Convert a file to opus frames. Supports any stream ffmpeg can read.

type Config

type Config struct {
	// Bitrate of opus data in bits per second. Default is 64000.
	Bitrate int
	// Logger directs log output. If not set, then the default Go logger is used.
	Logger *log.Logger
}

type Conn

type Conn struct {
	// contains filtered or unexported fields
}

Conn represents an active connection to a voice channel

func (*Conn) Close

func (c *Conn) Close()

Close leaves the current channel immediately

func (*Conn) Play

func (c *Conn) Play(ctx context.Context, r io.Reader) error

Play a file to a voice connection. Supports any stream ffmpeg can read.

func (*Conn) WriteFrame

func (c *Conn) WriteFrame(ctx context.Context, frame []byte) error

WriteFrame sends a single opus frame to the channel

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler makes voice connections to a discord session

func New

func New(s *discordgo.Session, cfg Config) (*Handler, error)

New creates a voice handler for a discord session. cfg gives optional parameters to control voice behavior.

func (*Handler) Join

func (h *Handler) Join(ctx context.Context, guildID, channelID string) (*Conn, error)

Join inititates a connection to a voice channel.

Returns a Conn which can be used to play audio. Accepts a context which can cancel the join operation.

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier