Documentation
¶
Index ¶
- func DecodeResponse(data []byte, v interface{}) error
- func EncodeRequest(v interface{}) ([]byte, error)
- type LavalinkClient
- type LoopRequest
- type Node
- type NodeManager
- type PauseRequest
- type PlayRequest
- type Player
- func (p *Player) Next() error
- func (p *Player) Pause() error
- func (p *Player) Play(trackID string) error
- func (p *Player) Prev() error
- func (p *Player) Resume() error
- func (p *Player) Seek(position int64) error
- func (p *Player) SetLoop(loop bool) error
- func (p *Player) SetVolume(volume int) error
- func (p *Player) SkipTo(index int) error
- func (p *Player) Stop() error
- type PlayerUpdate
- type Queue
- func (q *Queue) AddTrack(track *Track)
- func (q *Queue) IndexOfTrack(trackIdentifier string) int
- func (q *Queue) List() []*Track
- func (q *Queue) Next(currentIndex int) (*Track, error)
- func (q *Queue) Prev(currentIndex int) (*Track, error)
- func (q *Queue) RemoveTrack(index int) error
- func (q *Queue) SkipTo(index int) (*Track, error)
- type QueueManager
- type SeekRequest
- type StopRequest
- type Track
- type VolumeRequest
- type WebSocketClient
- type WebSocketClosedEvent
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeResponse ¶
Helper functions to decode responses from JSON
func EncodeRequest ¶
Helper functions to encode requests to JSON
Types ¶
type LavalinkClient ¶
type LavalinkClient struct {
NodeManager *NodeManager
Players map[string]*Player
}
func NewLavalinkClient ¶
func NewLavalinkClient() *LavalinkClient
func (*LavalinkClient) AddNode ¶
func (c *LavalinkClient) AddNode(host string, port int, password string) error
func (*LavalinkClient) GetPlayer ¶
func (c *LavalinkClient) GetPlayer(guildID string) *Player
func (*LavalinkClient) RemovePlayer ¶
func (c *LavalinkClient) RemovePlayer(guildID string)
type LoopRequest ¶
func NewLoopRequest ¶
func NewLoopRequest(guildID string, loop bool) *LoopRequest
type NodeManager ¶
func NewNodeManager ¶
func NewNodeManager() *NodeManager
func (*NodeManager) AddNode ¶
func (m *NodeManager) AddNode(host string, port int, password string) error
func (*NodeManager) GetLeastLoadedNode ¶
func (m *NodeManager) GetLeastLoadedNode() *Node
func (*NodeManager) RemoveNode ¶
func (m *NodeManager) RemoveNode(host string, port int)
type PauseRequest ¶
func NewPauseRequest ¶
func NewPauseRequest(guildID string, pause bool) *PauseRequest
type PlayRequest ¶
type PlayRequest struct {
GuildID string `json:"guildId"`
Track string `json:"track"`
StartTime int64 `json:"startTime,omitempty"`
EndTime int64 `json:"endTime,omitempty"`
Volume int `json:"volume,omitempty"`
}
Define request structures
func NewPlayRequest ¶
func NewPlayRequest(guildID, track string) *PlayRequest
Helper functions to create requests
type Player ¶
type PlayerUpdate ¶
type Queue ¶
type Queue struct {
Tracks []*Track
// contains filtered or unexported fields
}
Queue represents a queue of tracks to be played.
func (*Queue) IndexOfTrack ¶
IndexOfTrack returns the index of the track with the given Identifier, or -1 if not found.
func (*Queue) RemoveTrack ¶
RemoveTrack removes a track from the queue by index.
type QueueManager ¶
type QueueManager struct {
// contains filtered or unexported fields
}
QueueManager manages multiple queues, one per guild.
func NewQueueManager ¶
func NewQueueManager() *QueueManager
NewQueueManager creates a new QueueManager instance.
func (*QueueManager) GetQueue ¶
func (qm *QueueManager) GetQueue(guildIdentifier string) *Queue
GetQueue retrieves the queue for a given guild Identifier, creating it if it doesn't exist.
func (*QueueManager) RemoveQueue ¶
func (qm *QueueManager) RemoveQueue(guildIdentifier string)
RemoveQueue removes the queue for a given guild Identifier.
type SeekRequest ¶
func NewSeekRequest ¶
func NewSeekRequest(guildID string, position int64) *SeekRequest
type StopRequest ¶
type StopRequest struct {
GuildID string `json:"guildId"`
}
func NewStopRequest ¶
func NewStopRequest(guildID string) *StopRequest
type Track ¶
type Track struct {
Identifier string `json:"identifier"`
IsSeekable bool `json:"isSeekable"`
Author string `json:"author"`
Length int64 `json:"length"`
IsStream bool `json:"isStream"`
Title string `json:"title"`
URI string `json:"uri"`
}
Define response structures
type VolumeRequest ¶
func NewVolumeRequest ¶
func NewVolumeRequest(guildID string, volume int) *VolumeRequest
type WebSocketClient ¶
type WebSocketClient struct {
Conn *websocket.Conn
SendChannel chan []byte
ReceiveChannel chan []byte
CloseChannel chan struct{}
}
func NewWebSocketClient ¶
func NewWebSocketClient(url string, headers http.Header) (*WebSocketClient, error)
func (*WebSocketClient) Close ¶
func (c *WebSocketClient) Close()
Click to show internal directories.
Click to hide internal directories.