Documentation ¶
Index ¶
- Constants
- Variables
- type AudioLoadResultHandler
- type Client
- type Config
- type ConfigOpt
- type Endpoint
- type EventListener
- type EventPlugin
- type EventPlugins
- type FunctionalResultHandler
- func (h FunctionalResultHandler) LoadFailed(err error)
- func (h FunctionalResultHandler) NoMatches()
- func (h FunctionalResultHandler) PlaylistLoaded(playlist lavalink.Playlist)
- func (h FunctionalResultHandler) SearchResultLoaded(tracks []lavalink.Track)
- func (h FunctionalResultHandler) TrackLoaded(track lavalink.Track)
- type Node
- type NodeConfig
- type OpPlugin
- type Player
- type Plugin
- type PluginEventHandler
- type RestClient
- type Status
Constants ¶
View Source
const ( Name = "disgolink" Module = "github.com/disgoorg/disgolink/v3" GitHub = "https://github.com/disgoorg/disgo" )
Variables ¶
View Source
var ( EndpointBase Endpoint = "/v4" EndpointVersion Endpoint = "/version" EndpointInfo = EndpointBase + "/info" EndpointStats = EndpointBase + "/stats" EndpointUpdateSession = EndpointBase + "/sessions/%s" EndpointPlayers = EndpointBase + "/sessions/%s/players" EndpointPlayer = EndpointBase + "/sessions/%s/players/%s" EndpointUpdatePlayer = EndpointBase + "/sessions/%s/players/%s?noReplace=%t" EndpointDestroyPlayer = EndpointBase + "/sessions/%s/players/%s" EndpointLoadTracks = EndpointBase + "/loadtracks?identifier=%s" EndpointDecodeTrack = EndpointBase + "/decodetrack?track=%s" EndpointDecodeTracks = EndpointBase + "/decodetracks" EndpointWebSocket = EndpointBase + "/websocket" )
View Source
var ErrNodeAlreadyConnected = errors.New("node already connected")
View Source
var ErrPlayerNoNode = errors.New("player has no node")
View Source
var (
Version = getVersion()
)
Functions ¶
This section is empty.
Types ¶
type AudioLoadResultHandler ¶
type AudioLoadResultHandler interface { TrackLoaded(track lavalink.Track) PlaylistLoaded(playlist lavalink.Playlist) SearchResultLoaded(tracks []lavalink.Track) NoMatches() LoadFailed(err error) }
func NewResultHandler ¶
type Client ¶
type Client interface { AddNode(ctx context.Context, config NodeConfig) (Node, error) ForNodes(nodeFunc func(node Node)) Node(name string) Node BestNode() Node RemoveNode(name string) Player(guildID snowflake.ID) Player PlayerOnNode(node Node, guildID snowflake.ID) Player ExistingPlayer(guildID snowflake.ID) Player RemovePlayer(guildID snowflake.ID) ForPlayers(playerFunc func(player Player)) EmitEvent(player Player, event lavalink.Message) AddListeners(listeners ...EventListener) RemoveListeners(listeners ...EventListener) AddPlugins(plugins ...Plugin) ForPlugins(pluginFunc func(plugin Plugin)) RemovePlugins(plugins ...Plugin) UserID() snowflake.ID Close() OnVoiceServerUpdate(ctx context.Context, guildID snowflake.ID, token string, endpoint string) OnVoiceStateUpdate(ctx context.Context, guildID snowflake.ID, channelID *snowflake.ID, sessionID string) }
type Config ¶
type Config struct { Logger *slog.Logger HTTPClient *http.Client Listeners []EventListener Plugins []Plugin }
func DefaultConfig ¶
func DefaultConfig() *Config
type ConfigOpt ¶
type ConfigOpt func(config *Config)
func WithHTTPClient ¶
func WithListenerFunc ¶
func WithListeners ¶
func WithListeners(listeners ...EventListener) ConfigOpt
func WithLogger ¶
WithLogger lets you inject your own logger implementing log.Logger
func WithPlugins ¶
type EventListener ¶
func NewListenerFunc ¶
func NewListenerFunc[E lavalink.Message](f func(p Player, e E)) EventListener
type EventPlugin ¶
type EventPlugins ¶
type EventPlugins interface {
EventPlugins() []EventPlugin
}
type FunctionalResultHandler ¶
type FunctionalResultHandler struct {
// contains filtered or unexported fields
}
func (FunctionalResultHandler) LoadFailed ¶
func (h FunctionalResultHandler) LoadFailed(err error)
func (FunctionalResultHandler) NoMatches ¶
func (h FunctionalResultHandler) NoMatches()
func (FunctionalResultHandler) PlaylistLoaded ¶
func (h FunctionalResultHandler) PlaylistLoaded(playlist lavalink.Playlist)
func (FunctionalResultHandler) SearchResultLoaded ¶
func (h FunctionalResultHandler) SearchResultLoaded(tracks []lavalink.Track)
func (FunctionalResultHandler) TrackLoaded ¶
func (h FunctionalResultHandler) TrackLoaded(track lavalink.Track)
type Node ¶
type Node interface { Lavalink() Client Config() NodeConfig Rest() RestClient Stats() lavalink.Stats Status() Status SessionID() string Version(ctx context.Context) (string, error) Info(ctx context.Context) (*lavalink.Info, error) Update(ctx context.Context, update lavalink.SessionUpdate) error LoadTracks(ctx context.Context, identifier string) (*lavalink.LoadResult, error) LoadTracksHandler(ctx context.Context, identifier string, handler AudioLoadResultHandler) DecodeTrack(ctx context.Context, encodedTrack string) (*lavalink.Track, error) DecodeTracks(ctx context.Context, encodedTracks []string) ([]lavalink.Track, error) Open(ctx context.Context) error Close() }
type NodeConfig ¶
type NodeConfig struct { Name string `json:"name"` Address string `json:"address"` Password string `json:"password"` Secure bool `json:"secure"` SessionID string `json:"session_id"` }
func (NodeConfig) RestURL ¶
func (c NodeConfig) RestURL() string
func (NodeConfig) WsURL ¶
func (c NodeConfig) WsURL() string
type Player ¶
type Player interface { GuildID() snowflake.ID ChannelID() *snowflake.ID Track() *lavalink.Track Paused() bool Position() lavalink.Duration State() lavalink.PlayerState Volume() int Filters() lavalink.Filters Update(ctx context.Context, opts ...lavalink.PlayerUpdateOpt) error Destroy(ctx context.Context) error Lavalink() Client Node() Node Restore(player lavalink.Player) OnEvent(event lavalink.Event) OnPlayerUpdate(state lavalink.PlayerState) OnVoiceServerUpdate(ctx context.Context, token string, endpoint string) OnVoiceStateUpdate(ctx context.Context, channelID *snowflake.ID, sessionID string) }
type PluginEventHandler ¶
type RestClient ¶
type RestClient interface { // Do executes a http.Request and replaces the host and scheme with the node's config. It also sets the Authorization header to the node's password. It returns the http.Response or an error Do(rq *http.Request) (*http.Response, error) Version(ctx context.Context) (string, error) Info(ctx context.Context) (*lavalink.Info, error) Stats(ctx context.Context) (*lavalink.Stats, error) UpdateSession(ctx context.Context, sessionID string, sessionUpdate lavalink.SessionUpdate) (*lavalink.Session, error) Players(ctx context.Context, sessionID string) ([]lavalink.Player, error) Player(ctx context.Context, sessionID string, guildID snowflake.ID) (*lavalink.Player, error) UpdatePlayer(ctx context.Context, sessionID string, guildID snowflake.ID, playerUpdate lavalink.PlayerUpdate) (*lavalink.Player, error) DestroyPlayer(ctx context.Context, sessionID string, guildID snowflake.ID) error LoadTracks(ctx context.Context, identifier string) (*lavalink.LoadResult, error) DecodeTrack(ctx context.Context, encodedTrack string) (*lavalink.Track, error) DecodeTracks(ctx context.Context, encodedTracks []string) ([]lavalink.Track, error) }
Click to show internal directories.
Click to hide internal directories.