Documentation ¶
Index ¶
- Constants
- Variables
- type DummyEventHandler
- type EventHandler
- type Lavalink
- type Node
- type NodeConfig
- type Player
- func (player *Player) Destroy() error
- func (player *Player) Forward(sessionID string, event VoiceServerUpdate) error
- func (player *Player) GetVolume() int
- func (player *Player) GuildID() string
- func (player *Player) Pause(pause bool) error
- func (player *Player) Paused() bool
- func (player *Player) Play(track string) error
- func (player *Player) PlayAt(track string, startTime int, endTime int) error
- func (player *Player) Position() int
- func (player *Player) Seek(position int) error
- func (player *Player) Stop() error
- func (player *Player) Track() string
- func (player *Player) Volume(volume int) error
- type PlaylistInfo
- type Track
- type TrackInfo
- type Tracks
- type VoiceServerUpdate
Constants ¶
const ( // TrackLoaded is a Tracks Type for a succesful single track load TrackLoaded = "TRACK_LOADED" // PlaylistLoaded is a Tracks Type for a succseful playlist load PlaylistLoaded = "PLAYLIST_LOADED" // SearchResult is a Tracks Type for a search containing many tracks SearchResult = "SEARCH_RESULT" // NoMatches is a Tracks Type for a query yielding no matches NoMatches = "NO_MATCHES" // LoadFailed is a Tracks Type for an internal Lavalink error LoadFailed = "LOAD_FAILED" )
Variables ¶
var Log *log.Logger
Log sets the log.Logger gavalink will write to
Functions ¶
This section is empty.
Types ¶
type DummyEventHandler ¶
type DummyEventHandler struct{}
DummyEventHandler provides an empty event handler for users who wish to drop events outright. This is not recommended.
func (DummyEventHandler) OnTrackEnd ¶
func (d DummyEventHandler) OnTrackEnd(player *Player, track string, reason string) error
OnTrackEnd is raised when a track ends
func (DummyEventHandler) OnTrackException ¶
func (d DummyEventHandler) OnTrackException(player *Player, track string, reason string) error
OnTrackException is raised when a track throws an exception
func (DummyEventHandler) OnTrackStuck ¶
func (d DummyEventHandler) OnTrackStuck(player *Player, track string, threshold int) error
OnTrackStuck is raised when a track gets stuck
type EventHandler ¶
type EventHandler interface { OnTrackEnd(player *Player, track string, reason string) error OnTrackException(player *Player, track string, reason string) error OnTrackStuck(player *Player, track string, threshold int) error }
EventHandler defines events that Lavalink may send to a player
type Lavalink ¶
type Lavalink struct {
// contains filtered or unexported fields
}
Lavalink manages a connection to Lavalink Nodes
func NewLavalink ¶
NewLavalink creates a new Lavalink manager
func (*Lavalink) AddNodes ¶
func (lavalink *Lavalink) AddNodes(nodeConfigs ...NodeConfig) error
AddNodes adds a node to the Lavalink manager
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node wraps a Lavalink Node
func (*Node) CreatePlayer ¶
func (node *Node) CreatePlayer(guildID string, sessionID string, event VoiceServerUpdate, handler EventHandler) (*Player, error)
CreatePlayer creates an audio player on this node
func (*Node) LoadTracks ¶
LoadTracks queries lavalink to return a Tracks object
query should be a valid Lavaplayer query, including but not limited to: - A direct media URI - A direct Youtube /watch URI - A search query, prefixed with ytsearch: or scsearch:
See the Lavaplayer Source Code for all valid options.
type NodeConfig ¶
type NodeConfig struct { // REST is the host where Lavalink's REST server runs // // This value is expected without a trailing slash, e.g. like // `http://localhost:2333` REST string // WebSocket is the host where Lavalink's WebSocket server runs // // This value is expected without a trailing slash, e.g. like // `http://localhost:8012` WebSocket string // Password is the expected Authorization header for the Node Password string }
NodeConfig configures a Lavalink Node
type Player ¶
type Player struct {
// contains filtered or unexported fields
}
Player is a Lavalink player
func (*Player) Forward ¶
func (player *Player) Forward(sessionID string, event VoiceServerUpdate) error
Forward will forward a new VOICE_SERVER_UPDATE to a Lavalink node for this player.
This should always be used if a VOICE_SERVER_UPDATE is received for a guild which already has a player.
To move a player to a new Node, first player.Destroy() it, and then create a new player on the new node.
func (*Player) PlayAt ¶
PlayAt will play the given track at the specified start and end times
Setting a time to 0 will omit it.
type PlaylistInfo ¶
type PlaylistInfo struct { // Name is the friendly of the playlist Name string `json:"name"` // SelectedTrack is the index of the track that loaded the playlist, // if one is present. SelectedTrack int `json:"selectedTrack"` }
PlaylistInfo contains information about a loaded playlist
type Track ¶
type Track struct { // Data contains the base64 encoded Lavaplayer track Data string `json:"track"` Info TrackInfo `json:"info"` }
Track contains information about a loaded track
type TrackInfo ¶
type TrackInfo struct { Identifier string `json:"identifier"` Title string `json:"title"` Author string `json:"author"` URI string `json:"uri"` Seekable bool `json:"isSeekable"` Stream bool `json:"isStream"` Length int `json:"length"` Position int `json:"position"` }
TrackInfo contains more data about a loaded track
func DecodeString ¶
DecodeString decodes a base64 Lavaplayer string to a TrackInfo
type Tracks ¶
type Tracks struct { // Type contains the type of response // // This will be one of TrackLoaded, PlaylistLoaded, SearchResult, // NoMatches, or LoadFailed Type string `json:"loadType"` PlaylistInfo *PlaylistInfo `json:"playlistInfo"` Tracks []Track `json:"tracks"` }
Tracks contains data for a Lavalink Tracks response
type VoiceServerUpdate ¶
type VoiceServerUpdate struct { GuildID string `json:"guild_id"` Endpoint string `json:"endpoint"` Token string `json:"token"` }
VoiceServerUpdate is a raw Discord VOICE_SERVER_UPDATE event