Documentation
¶
Index ¶
- Variables
- func EncodeToString(info TrackInfo) (str *string, err error)
- type AudioLoaderResultHandler
- type CPU
- type DefaultTrack
- type DefaultTrackInfo
- func (i *DefaultTrackInfo) Author() string
- func (i *DefaultTrackInfo) Identifier() string
- func (i *DefaultTrackInfo) IsSeekable() bool
- func (i *DefaultTrackInfo) IsStream() bool
- func (i *DefaultTrackInfo) Length() int
- func (i *DefaultTrackInfo) Position() int
- func (i *DefaultTrackInfo) SourceName() string
- func (i *DefaultTrackInfo) Title() string
- func (i *DefaultTrackInfo) URI() *string
- type DestroyPlayerCommand
- type Disgolink
- type EndReason
- type EventCommand
- type Exception
- type FilterPlayerCommand
- type FrameStats
- type FunctionalResultHandler
- func (h *FunctionalResultHandler) LoadFailed(e *Exception)
- func (h *FunctionalResultHandler) NoMatches()
- func (h *FunctionalResultHandler) PlaylistLoaded(playlist *Playlist)
- func (h *FunctionalResultHandler) SearchResultLoaded(tracks []Track)
- func (h *FunctionalResultHandler) TrackLoaded(track Track)
- type GenericOp
- type GenericPlayerEvent
- type GenericTrackEvent
- type GenericWebsocketEvent
- type Lavalink
- type LoadResult
- type LoadType
- type Memory
- type Node
- type NodeOptions
- type NodeStatus
- type Op
- type PausePlayerCommand
- type PlayPlayerCommand
- type Player
- type PlayerCommand
- type PlayerEventListener
- type PlayerUpdateEvent
- type Playlist
- type PlaylistInfo
- type RestClient
- type SearchType
- type SeekPlayerCommand
- type Severity
- type State
- type Stats
- type StatsEvent
- type StopPlayerCommand
- type Track
- type TrackEndEvent
- type TrackExceptionEvent
- type TrackInfo
- type TrackStartEvent
- type TrackStuckEvent
- type VoiceServerUpdate
- type VoiceStateUpdate
- type VolumePlayerCommand
- type WebSocketClosedEvent
- type WebsocketEvent
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrEmptyTrack = errors.New("track is empty")
View Source
var ErrEmptyTrackInfo = errors.New("trackinfo is empty")
View Source
var SpotifyURIPattern = regexp.MustCompile("^spotify:(track|album|playlist):([a-zA-Z0-9-_]+)")
View Source
var SpotifyURLPattern = regexp.MustCompile("^(https?://)?(www\\.)?open\\.spotify\\.com/(track|album|playlist)/([a-zA-Z0-9-_]+)(\\?si=[a-zA-Z0-9-_]+)?")
SpotifyURLPattern is a spotify url pattern with regions to get track/album/playlist
View Source
var URLPattern = regexp.MustCompile("^(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]?")
URLPattern is a general url pattern
Functions ¶
func EncodeToString ¶
Types ¶
type AudioLoaderResultHandler ¶
type AudioLoaderResultHandler interface {
TrackLoaded(track Track)
PlaylistLoaded(playlist *Playlist)
SearchResultLoaded(tracks []Track)
NoMatches()
LoadFailed(e *Exception)
}
func NewResultHandler ¶
func NewResultHandler(trackLoaded func(track Track), playlistLoaded func(playlist *Playlist), searchResultLoaded func(tracks []Track), noMatches func(), loadFailed func(e *Exception)) AudioLoaderResultHandler
type DefaultTrack ¶
type DefaultTrack struct {
Track_ *string `json:"track"`
Info_ *DefaultTrackInfo `json:"info"`
}
func (*DefaultTrack) DecodeInfo ¶
func (t *DefaultTrack) DecodeInfo() (err error)
func (*DefaultTrack) EncodeInfo ¶
func (t *DefaultTrack) EncodeInfo() (err error)
func (*DefaultTrack) Info ¶
func (t *DefaultTrack) Info() TrackInfo
func (*DefaultTrack) Track ¶
func (t *DefaultTrack) Track() *string
type DefaultTrackInfo ¶
type DefaultTrackInfo struct {
Identifier_ string `json:"identifier"`
IsSeekable_ bool `json:"isSeekable"`
Author_ string `json:"author"`
Length_ int `json:"length"`
IsStream_ bool `json:"isStream"`
Position_ int `json:"position"`
Title_ string `json:"title"`
URI_ *string `json:"uri"`
SourceName_ string `json:"sourceName"`
}
func DecodeString ¶
func DecodeString(str string) (info *DefaultTrackInfo, err error)
DecodeString thx to https://github.com/foxbot/gavalink/blob/master/decoder.go
func (*DefaultTrackInfo) Author ¶
func (i *DefaultTrackInfo) Author() string
func (*DefaultTrackInfo) Identifier ¶
func (i *DefaultTrackInfo) Identifier() string
func (*DefaultTrackInfo) IsSeekable ¶
func (i *DefaultTrackInfo) IsSeekable() bool
func (*DefaultTrackInfo) IsStream ¶
func (i *DefaultTrackInfo) IsStream() bool
func (*DefaultTrackInfo) Length ¶
func (i *DefaultTrackInfo) Length() int
func (*DefaultTrackInfo) Position ¶
func (i *DefaultTrackInfo) Position() int
func (*DefaultTrackInfo) SourceName ¶
func (i *DefaultTrackInfo) SourceName() string
func (*DefaultTrackInfo) Title ¶
func (i *DefaultTrackInfo) Title() string
func (*DefaultTrackInfo) URI ¶
func (i *DefaultTrackInfo) URI() *string
type DestroyPlayerCommand ¶
type DestroyPlayerCommand struct {
PlayerCommand
}
type Disgolink ¶ added in v0.1.0
type Disgolink interface {
Lavalink
dapi.VoiceDispatchInterceptor
dapi.EventListener
}
type EventCommand ¶
type Exception ¶
type Exception struct {
Message string `json:"message"`
Severity Severity `json:"severity"`
Cause *string `json:"cause,omitempty"`
}
func NewException ¶
func NewExceptionFromErr ¶
type FilterPlayerCommand ¶
type FilterPlayerCommand struct {
PlayerCommand
*filters.Filters
}
type FrameStats ¶
type FunctionalResultHandler ¶
type FunctionalResultHandler struct {
// contains filtered or unexported fields
}
func (*FunctionalResultHandler) LoadFailed ¶
func (h *FunctionalResultHandler) LoadFailed(e *Exception)
func (*FunctionalResultHandler) NoMatches ¶
func (h *FunctionalResultHandler) NoMatches()
func (*FunctionalResultHandler) PlaylistLoaded ¶
func (h *FunctionalResultHandler) PlaylistLoaded(playlist *Playlist)
func (*FunctionalResultHandler) SearchResultLoaded ¶
func (h *FunctionalResultHandler) SearchResultLoaded(tracks []Track)
func (*FunctionalResultHandler) TrackLoaded ¶
func (h *FunctionalResultHandler) TrackLoaded(track Track)
type GenericPlayerEvent ¶
type GenericPlayerEvent struct {
GenericWebsocketEvent
GuildID string `json:"guildId"`
}
type GenericTrackEvent ¶
type GenericTrackEvent struct {
GenericPlayerEvent
RawTrack string `json:"track"`
}
func (GenericTrackEvent) Track ¶
func (e GenericTrackEvent) Track() Track
type GenericWebsocketEvent ¶
type GenericWebsocketEvent struct {
GenericOp
Type WebsocketEvent `json:"type"`
}
type Lavalink ¶
type Lavalink interface {
Logger() log.Logger
AddNode(options *NodeOptions)
Node(name string) Node
BestNode() Node
RemoveNode(name string)
Player(guildID string) Player
ExistingPlayer(guildID string) Player
Players() map[string]Player
RestClient() RestClient
UserID() string
ClientName() string
Close()
VoiceServerUpdate(voiceServerUpdate *VoiceServerUpdate)
VoiceStateUpdate(voiceStateUpdate *VoiceStateUpdate)
}
type LoadResult ¶
type LoadResult struct {
LoadType LoadType `json:"loadType"`
PlaylistInfo *PlaylistInfo `json:"playlistInfo"`
Tracks []*DefaultTrack `json:"tracks"`
Exception *Exception `json:"exception"`
}
type Node ¶
type Node interface {
Lavalink() Lavalink
Send(d interface{})
Open() error
Close()
Name() string
RestClient() RestClient
RestURL() string
Options() *NodeOptions
Stats() *Stats
}
type NodeOptions ¶
type NodeStatus ¶
type NodeStatus int
const ( Connecting NodeStatus = iota Reconnecting Disconnected )
Indicates how far along the client is to connecting
type Op ¶
type Op string
const ( OpPlay Op = "play" OpStop Op = "stop" OpPause Op = "pause" OpSeek Op = "seek" OpVolume Op = "volume" OpEqualizer Op = "equalizer" OpDestroy Op = "destroy" OpStats Op = "stats" OpVoiceUpdate Op = "voiceUpdate" OpPlayerUpdate Op = "playerUpdate" OpEvent Op = "event" OpConfigureResuming Op = "configureResuming" OpFilters Op = "filters" )
type PausePlayerCommand ¶
type PausePlayerCommand struct {
PlayerCommand
Pause bool `json:"pause"`
}
type PlayPlayerCommand ¶
type Player ¶
type Player interface {
Track() Track
SetTrack(track Track)
Play(track Track)
PlayAt(track Track, start int, end int)
Stop()
Destroy()
Pause(paused bool)
Paused() bool
Position() int
Seek(position int)
Volume() int
SetVolume(volume int)
Filters() *filters.Filters
SetFilters(filters *filters.Filters)
GuildID() string
ChannelID() *string
SetChannelID(channelID *string)
LastSessionID() *string
SetLastSessionID(sessionID string)
Node() Node
ChangeNode(node Node)
PlayerUpdate(state State)
EmitEvent(listenerCaller func(listener PlayerEventListener))
AddListener(playerListener PlayerEventListener)
RemoveListener(playerListener PlayerEventListener)
}
type PlayerCommand ¶
func NewPlayerCommand ¶
func NewPlayerCommand(op Op, p Player) PlayerCommand
type PlayerEventListener ¶
type PlayerEventListener interface {
OnPlayerPause(player Player)
OnPlayerResume(player Player)
OnPlayerUpdate(player Player, state State)
OnTrackStart(player Player, track Track)
OnTrackEnd(player Player, track Track, endReason EndReason)
OnTrackException(player Player, track Track, exception Exception)
OnTrackStuck(player Player, track Track, thresholdMs int)
OnWebSocketClosed(player Player, code int, reason string, byRemote bool)
}
type PlayerUpdateEvent ¶
type Playlist ¶
type Playlist struct {
Info *PlaylistInfo
Tracks []Track
}
func NewPlaylist ¶
func NewPlaylist(result *LoadResult) *Playlist
func (Playlist) SelectedTrack ¶
type PlaylistInfo ¶
type RestClient ¶
type RestClient interface {
SearchItem(searchType SearchType, query string) ([]Track, *Exception)
LoadItemAsync(identifier string, audioLoaderResultHandler AudioLoaderResultHandler)
LoadItem(identifier string) (*LoadResult, error)
}
type SearchType ¶
type SearchType string
const ( SearchTypeYoutube SearchType = "ytsearch:" SearchTypeYoutubeMusic SearchType = "ytmsearch:" SearchTypeSoundCloud SearchType = "scsearch:" )
search prefixes
func (SearchType) Apply ¶
func (t SearchType) Apply(searchString string) string
type SeekPlayerCommand ¶
type SeekPlayerCommand struct {
PlayerCommand
Position int `json:"position"`
}
type Stats ¶
type StatsEvent ¶
type StopPlayerCommand ¶
type StopPlayerCommand struct {
PlayerCommand
}
type Track ¶
func DefaultTracksToTracks ¶
func DefaultTracksToTracks(defaultTracks []*DefaultTrack) []Track
type TrackEndEvent ¶
type TrackEndEvent struct {
GenericTrackEvent
EndReason EndReason `json:"reason"`
}
type TrackExceptionEvent ¶
type TrackExceptionEvent struct {
GenericTrackEvent
Exception Exception `json:"exception"`
}
type TrackStartEvent ¶
type TrackStartEvent struct {
GenericTrackEvent
}
type TrackStuckEvent ¶
type TrackStuckEvent struct {
GenericTrackEvent
ThresholdMs int `json:"thresholdMs"`
}
type VoiceServerUpdate ¶
type VoiceStateUpdate ¶
type VolumePlayerCommand ¶
type VolumePlayerCommand struct {
PlayerCommand
Volume int `json:"volume"`
}
type WebSocketClosedEvent ¶
type WebSocketClosedEvent struct {
GenericPlayerEvent
Code int `json:"code"`
Reason string `json:"reason"`
ByRemote bool `json:"byRemote"`
}
type WebsocketEvent ¶
type WebsocketEvent string
const ( WebsocketEventTrackStart WebsocketEvent = "TrackStartEvent" WebsocketEventTrackEnd WebsocketEvent = "TrackEndEvent" WebsocketEventTrackException WebsocketEvent = "TrackExceptionEvent" WebsocketEventTrackStuck WebsocketEvent = "TrackStuckEvent" WebSocketEventClosed WebsocketEvent = "WebSocketClosedEvent" )
Source Files
¶
Click to show internal directories.
Click to hide internal directories.