lavalink

package module
v1.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 27, 2022 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Millisecond Duration = 1
	Second               = 1000 * Millisecond
	Minute               = 60 * Second
	Hour                 = 60 * Minute
	Day                  = 24 * Hour
)
View Source
const (
	GitHub = "https://github.com/DisgoOrg/disgolink"
	Name   = "disgolink"
)

Variables

View Source
var ErrInvalidBotToken = errors.New("invalid bot token")
View Source
var ErrNoUserID = errors.New("no user id has been configured")
View Source
var UnmarshalFilters = func(data []byte) (Filters, error) {
	var filters *DefaultFilters
	if err := json.Unmarshal(data, &filters); err != nil {
		return nil, errors.Wrap(err, "error while unmarshalling filters")
	}
	return filters, nil
}
View Source
var (
	Version = getVersion()
)

Functions

func EncodeToString

func EncodeToString(track AudioTrack, customTrackEncoder CustomTrackEncoder) (str string, err error)

func ReadBool

func ReadBool(r io.Reader) (b bool, err error)

func ReadInt16

func ReadInt16(r io.Reader) (i int16, err error)

func ReadInt32

func ReadInt32(r io.Reader) (i int32, err error)

func ReadInt64

func ReadInt64(r io.Reader) (i int64, err error)

func ReadInt8

func ReadInt8(r io.Reader) (i int8, err error)

func ReadNullableString

func ReadNullableString(r io.Reader) (*string, error)

func ReadString

func ReadString(r io.Reader) (string, error)

func UserIDFromBotToken added in v1.3.3

func UserIDFromBotToken(token string) (snowflake.Snowflake, error)

func WriteBool

func WriteBool(w io.Writer, bool bool) error

func WriteInt16

func WriteInt16(w io.Writer, i int16) error

func WriteInt32

func WriteInt32(w io.Writer, i int32) error

func WriteInt64

func WriteInt64(w io.Writer, i int64) error

func WriteNullableString

func WriteNullableString(w io.Writer, str *string) error

func WriteString

func WriteString(w io.Writer, str string) error

Types

type AudioLoadResultHandler

type AudioLoadResultHandler interface {
	TrackLoaded(track AudioTrack)
	PlaylistLoaded(playlist AudioPlaylist)
	SearchResultLoaded(tracks []AudioTrack)
	NoMatches()
	LoadFailed(e FriendlyException)
}

func NewResultHandler

func NewResultHandler(trackLoaded func(track AudioTrack), playlistLoaded func(playlist AudioPlaylist), searchResultLoaded func(tracks []AudioTrack), noMatches func(), loadFailed func(e FriendlyException)) AudioLoadResultHandler

type AudioPlaylist

type AudioPlaylist interface {
	Name() string
	Tracks() []AudioTrack
	SelectedTrack() AudioTrack
}

func NewAudioPlaylist

func NewAudioPlaylist(name string, selectedTrackIndex int, tracks []AudioTrack) AudioPlaylist

type AudioTrack

type AudioTrack interface {
	Info() AudioTrackInfo
	SetPosition(position Duration)
	UserData() interface{}
	SetUserData(interface{})
	Clone() AudioTrack
}

func DecodeString

func DecodeString(str string, customTrackInfoDecoder CustomTrackInfoDecoder) (track AudioTrack, err error)

func NewAudioTrack

func NewAudioTrack(info AudioTrackInfo) AudioTrack

type AudioTrackEndReason

type AudioTrackEndReason string
const (
	AudioTrackEndReasonFinished   AudioTrackEndReason = "FINISHED"
	AudioTrackEndReasonLoadFailed AudioTrackEndReason = "LOAD_FAILED"
	AudioTrackEndReasonStopped    AudioTrackEndReason = "STOPPED"
	AudioTrackEndReasonReplaced   AudioTrackEndReason = "REPLACED"
	AudioTrackEndReasonCleanup    AudioTrackEndReason = "CLEANUP"
)

func (AudioTrackEndReason) MayStartNext

func (e AudioTrackEndReason) MayStartNext() bool

type AudioTrackInfo

type AudioTrackInfo struct {
	Identifier string   `json:"identifier"`
	Author     string   `json:"author"`
	Length     Duration `json:"length"`
	IsStream   bool     `json:"isStream"`
	Title      string   `json:"title"`
	URI        *string  `json:"uri"`
	SourceName string   `json:"sourceName"`
	Position   Duration `json:"position"`
}

type BasicAudioPlaylist added in v1.4.0

type BasicAudioPlaylist struct {
	PlaylistName       string
	SelectedTrackIndex int
	PlaylistTracks     []AudioTrack
}

func (BasicAudioPlaylist) Name added in v1.4.0

func (p BasicAudioPlaylist) Name() string

func (BasicAudioPlaylist) SelectedTrack added in v1.4.0

func (p BasicAudioPlaylist) SelectedTrack() AudioTrack

func (BasicAudioPlaylist) Tracks added in v1.4.0

func (p BasicAudioPlaylist) Tracks() []AudioTrack

type BasicAudioTrack added in v1.4.0

type BasicAudioTrack struct {
	AudioTrackInfo AudioTrackInfo `json:"info"`
	// contains filtered or unexported fields
}

func (*BasicAudioTrack) Clone added in v1.4.0

func (t *BasicAudioTrack) Clone() AudioTrack

func (*BasicAudioTrack) Info added in v1.4.0

func (t *BasicAudioTrack) Info() AudioTrackInfo

func (*BasicAudioTrack) SetPosition added in v1.4.0

func (t *BasicAudioTrack) SetPosition(position Duration)

func (*BasicAudioTrack) SetUserData added in v1.4.0

func (t *BasicAudioTrack) SetUserData(userData interface{})

func (*BasicAudioTrack) UserData added in v1.4.0

func (t *BasicAudioTrack) UserData() interface{}

type CPU

type CPU struct {
	Cores        int     `json:"cores"`
	SystemLoad   float64 `json:"systemLoad"`
	LavalinkLoad float64 `json:"lavalinkLoad"`
}

type Config

type Config struct {
	Logger     log.Logger
	HTTPClient *http.Client
	UserID     snowflake.Snowflake
	Plugins    []interface{}
}

func (*Config) Apply

func (c *Config) Apply(opts []ConfigOpt)

type ConfigOpt

type ConfigOpt func(config *Config)

func WithHTTPClient

func WithHTTPClient(httpClient *http.Client) ConfigOpt

func WithLogger

func WithLogger(logger log.Logger) ConfigOpt

WithLogger lets you inject your own logger implementing log.Logger

func WithPlugins

func WithPlugins(plugins ...interface{}) ConfigOpt

func WithUserID

func WithUserID(userID snowflake.Snowflake) ConfigOpt

func WithUserIDFromBotToken added in v1.3.3

func WithUserIDFromBotToken(botToken string) ConfigOpt

func WithUserIDString added in v1.3.3

func WithUserIDString(userID string) ConfigOpt

type ConfigureResumingCommand

type ConfigureResumingCommand struct {
	Key     string `json:"key"`
	Timeout int    `json:"timeout"`
}

func (ConfigureResumingCommand) MarshalJSON

func (c ConfigureResumingCommand) MarshalJSON() ([]byte, error)

func (ConfigureResumingCommand) Op

func (ConfigureResumingCommand) OpCommand

func (ConfigureResumingCommand) OpCommand()

type CustomTrackEncoder

type CustomTrackEncoder func(track AudioTrack, w io.Writer) error

type CustomTrackInfoDecoder

type CustomTrackInfoDecoder func(info AudioTrackInfo, r io.Reader) (AudioTrack, error)

type DefaultFilters added in v1.4.0

type DefaultFilters struct {
	FilterVolume     *Volume     `json:"volume,omitempty"`
	FilterEqualizer  *Equalizer  `json:"equalizer,omitempty"`
	FilterTimescale  *Timescale  `json:"timescale,omitempty"`
	FilterTremolo    *Tremolo    `json:"tremolo,omitempty"`
	FilterVibrato    *Vibrato    `json:"vibrato,omitempty"`
	FilterRotation   *Rotation   `json:"rotation,omitempty"`
	FilterKaraoke    *Karaoke    `json:"karaoke,omitempty"`
	FilterDistortion *Distortion `json:"distortion,omitempty"`
	// contains filtered or unexported fields
}

func (*DefaultFilters) Clear added in v1.4.0

func (f *DefaultFilters) Clear() Filters

func (*DefaultFilters) Commit added in v1.4.0

func (f *DefaultFilters) Commit() error

func (*DefaultFilters) Distortion added in v1.4.0

func (f *DefaultFilters) Distortion() *Distortion

func (*DefaultFilters) Equalizer added in v1.4.0

func (f *DefaultFilters) Equalizer() *Equalizer

func (*DefaultFilters) Karaoke added in v1.4.0

func (f *DefaultFilters) Karaoke() *Karaoke

func (*DefaultFilters) Rotation added in v1.4.0

func (f *DefaultFilters) Rotation() *Rotation

func (*DefaultFilters) SetDistortion added in v1.4.0

func (f *DefaultFilters) SetDistortion(distortion *Distortion) Filters

func (*DefaultFilters) SetEqualizer added in v1.4.0

func (f *DefaultFilters) SetEqualizer(equalizer *Equalizer) Filters

func (*DefaultFilters) SetKaraoke added in v1.4.0

func (f *DefaultFilters) SetKaraoke(karaoke *Karaoke) Filters

func (*DefaultFilters) SetRotation added in v1.4.0

func (f *DefaultFilters) SetRotation(rotation *Rotation) Filters

func (*DefaultFilters) SetTimescale added in v1.4.0

func (f *DefaultFilters) SetTimescale(timescale *Timescale) Filters

func (*DefaultFilters) SetTremolo added in v1.4.0

func (f *DefaultFilters) SetTremolo(tremolo *Tremolo) Filters

func (*DefaultFilters) SetVibrato added in v1.4.0

func (f *DefaultFilters) SetVibrato(vibrato *Vibrato) Filters

func (*DefaultFilters) SetVolume added in v1.4.0

func (f *DefaultFilters) SetVolume(volume *Volume) Filters

func (*DefaultFilters) Timescale added in v1.4.0

func (f *DefaultFilters) Timescale() *Timescale

func (*DefaultFilters) Tremolo added in v1.4.0

func (f *DefaultFilters) Tremolo() *Tremolo

func (*DefaultFilters) Vibrato added in v1.4.0

func (f *DefaultFilters) Vibrato() *Vibrato

func (*DefaultFilters) Volume added in v1.4.0

func (f *DefaultFilters) Volume() *Volume

type DefaultPlayer

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

func (*DefaultPlayer) AddListener

func (p *DefaultPlayer) AddListener(listener interface{})

func (*DefaultPlayer) ChangeNode added in v1.4.0

func (p *DefaultPlayer) ChangeNode(node Node)

func (*DefaultPlayer) ChannelID

func (p *DefaultPlayer) ChannelID() *snowflake.Snowflake

func (*DefaultPlayer) Connected added in v1.3.1

func (p *DefaultPlayer) Connected() bool

func (*DefaultPlayer) Destroy

func (p *DefaultPlayer) Destroy() error

func (*DefaultPlayer) EmitEvent

func (p *DefaultPlayer) EmitEvent(caller func(l interface{}))

func (*DefaultPlayer) Export added in v1.4.0

func (p *DefaultPlayer) Export() PlayerRestoreState

func (*DefaultPlayer) Filters

func (p *DefaultPlayer) Filters() Filters

func (*DefaultPlayer) GuildID

func (p *DefaultPlayer) GuildID() snowflake.Snowflake

func (*DefaultPlayer) Node

func (p *DefaultPlayer) Node() Node

func (*DefaultPlayer) OnPlayerUpdate added in v1.4.0

func (p *DefaultPlayer) OnPlayerUpdate(state PlayerState)

func (*DefaultPlayer) OnVoiceServerUpdate added in v1.4.0

func (p *DefaultPlayer) OnVoiceServerUpdate(voiceServerUpdate VoiceServerUpdate)

func (*DefaultPlayer) OnVoiceStateUpdate added in v1.4.0

func (p *DefaultPlayer) OnVoiceStateUpdate(voiceStateUpdate VoiceStateUpdate)

func (*DefaultPlayer) Pause

func (p *DefaultPlayer) Pause(pause bool) error

func (*DefaultPlayer) Paused

func (p *DefaultPlayer) Paused() bool

func (*DefaultPlayer) Play

func (p *DefaultPlayer) Play(track AudioTrack) error

func (*DefaultPlayer) PlayAt

func (p *DefaultPlayer) PlayAt(track AudioTrack, start Duration, end Duration) error

func (*DefaultPlayer) PlayingTrack added in v1.4.0

func (p *DefaultPlayer) PlayingTrack() AudioTrack

func (*DefaultPlayer) Position

func (p *DefaultPlayer) Position() Duration

func (*DefaultPlayer) RemoveListener

func (p *DefaultPlayer) RemoveListener(listener interface{})

func (*DefaultPlayer) Seek

func (p *DefaultPlayer) Seek(position Duration) error

func (*DefaultPlayer) SetFilters

func (p *DefaultPlayer) SetFilters(filters Filters)

func (*DefaultPlayer) SetVolume

func (p *DefaultPlayer) SetVolume(volume int) error

func (*DefaultPlayer) Stop

func (p *DefaultPlayer) Stop() error

func (*DefaultPlayer) Volume

func (p *DefaultPlayer) Volume() int

type DestroyCommand

type DestroyCommand struct {
	GuildID snowflake.Snowflake `json:"guildId"`
}

func (DestroyCommand) MarshalJSON

func (c DestroyCommand) MarshalJSON() ([]byte, error)

func (DestroyCommand) Op

func (DestroyCommand) Op() OpType

func (DestroyCommand) OpCommand

func (DestroyCommand) OpCommand()

type Distortion

type Distortion struct {
	SinOffset int `json:"sinOffset"`
	SinScale  int `json:"sinScale"`
	CosOffset int `json:"cosOffset"`
	CosScale  int `json:"cosScale"`
	TanOffset int `json:"tanOffset"`
	TanScale  int `json:"tanScale"`
	Offset    int `json:"offset"`
	Scale     int `json:"scale"`
}

type Duration added in v1.3.0

type Duration int64

func (Duration) Days added in v1.3.0

func (d Duration) Days() int64

func (Duration) Hours added in v1.3.0

func (d Duration) Hours() int64

func (Duration) HoursPart added in v1.3.0

func (d Duration) HoursPart() int64

func (Duration) Milliseconds added in v1.3.0

func (d Duration) Milliseconds() int64

func (Duration) MillisecondsPart added in v1.3.0

func (d Duration) MillisecondsPart() int64

func (Duration) Minutes added in v1.3.0

func (d Duration) Minutes() int64

func (Duration) MinutesPart added in v1.3.0

func (d Duration) MinutesPart() int64

func (Duration) Seconds added in v1.3.0

func (d Duration) Seconds() int64

func (Duration) SecondsPart added in v1.3.0

func (d Duration) SecondsPart() int64

func (Duration) String added in v1.3.0

func (d Duration) String() string

type EqBand

type EqBand struct {
	Band int     `json:"band"`
	Gain float32 `json:"gain"`
}

type Equalizer

type Equalizer [15]float32

func (Equalizer) MarshalJSON

func (e Equalizer) MarshalJSON() ([]byte, error)

MarshalJSON marshals the map as object array

type EventExtension

type EventExtension interface {
	Event() EventType
	OnEventInvocation(node Node, data []byte)
}

type EventExtensions

type EventExtensions interface {
	EventExtensions() []EventExtension
}

type EventType

type EventType string
const (
	EventTypeTrackStart      EventType = "TrackStartEvent"
	EventTypeTrackEnd        EventType = "TrackEndEvent"
	EventTypeTrackException  EventType = "TrackExceptionEvent"
	EventTypeTrackStuck      EventType = "TrackStuckEvent"
	EventTypeWebSocketClosed EventType = "WebSocketClosedEvent"
)

type Filters

type Filters interface {
	Volume() *Volume
	Equalizer() *Equalizer
	Timescale() *Timescale
	Tremolo() *Tremolo
	Vibrato() *Vibrato
	Rotation() *Rotation
	Karaoke() *Karaoke
	Distortion() *Distortion

	SetVolume(v *Volume) Filters
	SetEqualizer(equalizer *Equalizer) Filters
	SetTimescale(timescale *Timescale) Filters
	SetTremolo(tremolo *Tremolo) Filters
	SetVibrato(vibrato *Vibrato) Filters
	SetRotation(rotation *Rotation) Filters
	SetKaraoke(karaoke *Karaoke) Filters
	SetDistortion(distortion *Distortion) Filters

	Clear() Filters
	Commit() error
	// contains filtered or unexported methods
}

func NewFilters

func NewFilters(commitFunc func(filters Filters) error) Filters

type FiltersCommand

type FiltersCommand struct {
	GuildID snowflake.Snowflake `json:"guildId"`
	Filters
}

func (FiltersCommand) MarshalJSON

func (c FiltersCommand) MarshalJSON() ([]byte, error)

func (FiltersCommand) Op

func (FiltersCommand) Op() OpType

func (FiltersCommand) OpCommand

func (FiltersCommand) OpCommand()

type FrameStats

type FrameStats struct {
	Sent    int `json:"sent"`
	Nulled  int `json:"nulled"`
	Deficit int `json:"deficit"`
}

type FriendlyException

type FriendlyException struct {
	Message  string   `json:"message"`
	Severity Severity `json:"severity"`
	Cause    *string  `json:"cause,omitempty"`
}

func (FriendlyException) Error

func (e FriendlyException) Error() string

type FunctionalResultHandler

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

func (FunctionalResultHandler) LoadFailed

func (FunctionalResultHandler) NoMatches

func (h FunctionalResultHandler) NoMatches()

func (FunctionalResultHandler) PlaylistLoaded

func (h FunctionalResultHandler) PlaylistLoaded(playlist AudioPlaylist)

func (FunctionalResultHandler) SearchResultLoaded

func (h FunctionalResultHandler) SearchResultLoaded(tracks []AudioTrack)

func (FunctionalResultHandler) TrackLoaded

func (h FunctionalResultHandler) TrackLoaded(track AudioTrack)

type Karaoke

type Karaoke struct {
	Level       float32 `json:"level"`
	MonoLevel   float32 `json:"monoLevel"`
	FilterBand  float32 `json:"filterBand"`
	FilterWidth float32 `json:"filterWidth"`
}
type Lavalink interface {
	Logger() log.Logger

	AddNode(ctx context.Context, config NodeConfig) (Node, error)
	Nodes() []Node
	Node(name string) Node
	BestNode() Node
	BestRestClient() RestClient
	RemoveNode(name string)

	AddPlugins(plugins ...interface{})
	Plugins() []interface{}
	RemovePlugins(plugins ...interface{})

	EncodeTrack(track AudioTrack) (string, error)
	DecodeTrack(track string) (AudioTrack, error)

	Player(guildID snowflake.Snowflake) Player
	PlayerOnNode(name string, guildID snowflake.Snowflake) Player
	RestorePlayer(restoreState PlayerRestoreState) (Player, error)
	ExistingPlayer(guildID snowflake.Snowflake) Player
	RemovePlayer(guildID snowflake.Snowflake)
	Players() map[snowflake.Snowflake]Player

	UserID() snowflake.Snowflake
	SetUserID(userID snowflake.Snowflake)

	Close()

	OnVoiceServerUpdate(voiceServerUpdate VoiceServerUpdate)
	OnVoiceStateUpdate(voiceStateUpdate VoiceStateUpdate)
}

func New

func New(opts ...ConfigOpt) Lavalink

type LoadResult

type LoadResult struct {
	LoadType     LoadType           `json:"loadType"`
	PlaylistInfo *PlaylistInfo      `json:"playlistInfo"`
	Tracks       []RestAudioTrack   `json:"tracks"`
	Exception    *FriendlyException `json:"exception"`
}

type LoadType

type LoadType string
const (
	LoadTypeTrackLoaded    LoadType = "TRACK_LOADED"
	LoadTypePlaylistLoaded LoadType = "PLAYLIST_LOADED"
	LoadTypeSearchResult   LoadType = "SEARCH_RESULT"
	LoadTypeNoMatches      LoadType = "NO_MATCHES"
	LoadTypeLoadFailed     LoadType = "LOAD_FAILED"
)

type Memory

type Memory struct {
	Free       int `json:"free"`
	Used       int `json:"used"`
	Allocated  int `json:"allocated"`
	Reservable int `json:"reservable"`
}

type Node

type Node interface {
	Lavalink() Lavalink
	Send(cmd OpCommand) error
	ConfigureResuming(key string, timeoutSeconds int) error

	Open(ctx context.Context) error
	Close()

	Name() string
	RestClient() RestClient
	RestURL() string
	Config() NodeConfig
	Stats() *Stats
	Status() NodeStatus
}

type NodeConfig

type NodeConfig struct {
	Name        string `json:"name"`
	Host        string `json:"host"`
	Port        string `json:"port"`
	Password    string `json:"password"`
	Secure      bool   `json:"secure"`
	ResumingKey string `json:"resumingKey"`
}

type NodeStatus

type NodeStatus string
const (
	Connecting   NodeStatus = "CONNECTING"
	Connected    NodeStatus = "CONNECTED"
	Reconnecting NodeStatus = "RECONNECTING"
	Disconnected NodeStatus = "DISCONNECTED"
)

Indicates how far along the client is to connecting

type Op

type Op interface {
	Op() OpType
}

type OpCommand

type OpCommand interface {
	json.Marshaler
	Op
	OpCommand()
}

type OpEvent

type OpEvent interface {
	Op
	Event() EventType
	GuildID() snowflake.Snowflake
	OpEvent()
}

type OpExtension

type OpExtension interface {
	Op() OpType
	OnOpInvocation(node Node, data []byte)
}

type OpExtensions

type OpExtensions interface {
	OpExtensions() []OpExtension
}

type OpType

type OpType string
const (
	OpTypePlay              OpType = "play"
	OpTypeStop              OpType = "stop"
	OpTypePause             OpType = "pause"
	OpTypeSeek              OpType = "seek"
	OpTypeVolume            OpType = "volume"
	OpTypeDestroy           OpType = "destroy"
	OpTypeStats             OpType = "stats"
	OpTypeVoiceUpdate       OpType = "voiceUpdate"
	OpTypePlayerUpdate      OpType = "playerUpdate"
	OpTypeEvent             OpType = "event"
	OpTypeConfigureResuming OpType = "configureResuming"
	OpTypeFilters           OpType = "filters"
)

type PauseCommand

type PauseCommand struct {
	GuildID snowflake.Snowflake `json:"guildId"`
	Pause   bool                `json:"pause"`
}

func (PauseCommand) MarshalJSON

func (c PauseCommand) MarshalJSON() ([]byte, error)

func (PauseCommand) Op

func (PauseCommand) Op() OpType

func (PauseCommand) OpCommand

func (PauseCommand) OpCommand()

type PlayCommand

type PlayCommand struct {
	GuildID   snowflake.Snowflake `json:"guildId"`
	Track     string              `json:"track"`
	StartTime *Duration           `json:"startTime,omitempty"`
	EndTime   *Duration           `json:"endTime,omitempty"`
	NoReplace bool                `json:"noReplace,omitempty"`
	Pause     bool                `json:"pause,omitempty"`
}

func (PlayCommand) MarshalJSON

func (c PlayCommand) MarshalJSON() ([]byte, error)

func (PlayCommand) Op

func (PlayCommand) Op() OpType

func (PlayCommand) OpCommand

func (PlayCommand) OpCommand()

type Player

type Player interface {
	PlayingTrack() AudioTrack
	Paused() bool
	Position() Duration
	Connected() bool
	Volume() int
	Filters() Filters
	GuildID() snowflake.Snowflake
	ChannelID() *snowflake.Snowflake
	Node() Node
	Export() PlayerRestoreState

	Play(track AudioTrack) error
	PlayAt(track AudioTrack, start Duration, end Duration) error
	Stop() error
	Destroy() error
	Pause(paused bool) error
	Seek(position Duration) error
	SetVolume(volume int) error
	SetFilters(filters Filters)
	ChangeNode(node Node)

	OnVoiceServerUpdate(voiceServerUpdate VoiceServerUpdate)
	OnVoiceStateUpdate(voiceStateUpdate VoiceStateUpdate)
	OnPlayerUpdate(state PlayerState)

	EmitEvent(caller func(l interface{}))
	AddListener(listener interface{})
	RemoveListener(listener interface{})
}

func NewPlayer

func NewPlayer(node Node, lavalink Lavalink, guildID snowflake.Snowflake) Player

type PlayerEventAdapter

type PlayerEventAdapter struct{}

func (PlayerEventAdapter) OnPlayerPause

func (a PlayerEventAdapter) OnPlayerPause(player Player)

func (PlayerEventAdapter) OnPlayerResume

func (a PlayerEventAdapter) OnPlayerResume(player Player)

func (PlayerEventAdapter) OnPlayerUpdate

func (a PlayerEventAdapter) OnPlayerUpdate(player Player, state PlayerState)

func (PlayerEventAdapter) OnTrackEnd

func (a PlayerEventAdapter) OnTrackEnd(player Player, track AudioTrack, endReason AudioTrackEndReason)

func (PlayerEventAdapter) OnTrackException

func (a PlayerEventAdapter) OnTrackException(player Player, track AudioTrack, exception FriendlyException)

func (PlayerEventAdapter) OnTrackStart

func (a PlayerEventAdapter) OnTrackStart(player Player, track AudioTrack)

func (PlayerEventAdapter) OnTrackStuck

func (a PlayerEventAdapter) OnTrackStuck(player Player, track AudioTrack, thresholdMs Duration)

func (PlayerEventAdapter) OnWebSocketClosed

func (a PlayerEventAdapter) OnWebSocketClosed(player Player, code int, reason string, byRemote bool)

type PlayerEventListener

type PlayerEventListener interface {
	OnPlayerPause(player Player)
	OnPlayerResume(player Player)
	OnPlayerUpdate(player Player, state PlayerState)
	OnTrackStart(player Player, track AudioTrack)
	OnTrackEnd(player Player, track AudioTrack, endReason AudioTrackEndReason)
	OnTrackException(player Player, track AudioTrack, exception FriendlyException)
	OnTrackStuck(player Player, track AudioTrack, thresholdMs Duration)
	OnWebSocketClosed(player Player, code int, reason string, byRemote bool)
}

type PlayerRestoreState added in v1.4.0

type PlayerRestoreState struct {
	PlayingTrack          *string              `json:"playing_track"`
	Paused                bool                 `json:"paused"`
	State                 PlayerState          `json:"state"`
	Volume                int                  `json:"volume"`
	Filters               Filters              `json:"filters"`
	GuildID               snowflake.Snowflake  `json:"guild_id"`
	ChannelID             *snowflake.Snowflake `json:"channel_id"`
	LastSessionID         *string              `json:"last_session_id"`
	LastVoiceServerUpdate *VoiceServerUpdate   `json:"last_voice_server_update"`
	Node                  string               `json:"node"`
}

func (*PlayerRestoreState) UnmarshalJSON added in v1.4.0

func (s *PlayerRestoreState) UnmarshalJSON(data []byte) error

type PlayerState

type PlayerState struct {
	Time      Time     `json:"time"`
	Position  Duration `json:"position"`
	Connected bool     `json:"connected"`
}

type PlayerUpdateOp

type PlayerUpdateOp struct {
	GuildID snowflake.Snowflake `json:"guildId"`
	State   PlayerState         `json:"state"`
}

func (PlayerUpdateOp) Op

func (PlayerUpdateOp) Op() OpType

type PlaylistInfo added in v1.4.0

type PlaylistInfo struct {
	Name          string `json:"name"`
	SelectedTrack int    `json:"selectedTrack"`
}

type Plugin

type Plugin struct {
	Name    string `json:"name"`
	Version string `json:"version"`
}

type PluginEventAdapter

type PluginEventAdapter struct{}

func (PluginEventAdapter) OnDestroyPlayer

func (a PluginEventAdapter) OnDestroyPlayer(player Player)

func (PluginEventAdapter) OnNewPlayer

func (a PluginEventAdapter) OnNewPlayer(player Player)

func (PluginEventAdapter) OnNodeDestroy

func (a PluginEventAdapter) OnNodeDestroy(node Node)

func (PluginEventAdapter) OnNodeMessageIn

func (a PluginEventAdapter) OnNodeMessageIn(node Node, data []byte)

func (PluginEventAdapter) OnNodeMessageOut

func (a PluginEventAdapter) OnNodeMessageOut(node Node, data []byte)

func (PluginEventAdapter) OnNodeOpen

func (a PluginEventAdapter) OnNodeOpen(node Node)

type PluginEventHandler

type PluginEventHandler interface {
	OnNodeOpen(node Node)
	OnNodeDestroy(node Node)
	OnNodeMessageIn(node Node, data []byte)
	OnNodeMessageOut(node Node, data []byte)
	OnNewPlayer(player Player)
	OnDestroyPlayer(player Player)
}

type RestAudioTrack added in v1.4.0

type RestAudioTrack struct {
	Track string         `json:"track"`
	Info  AudioTrackInfo `json:"info"`
}

type RestClient

type RestClient interface {
	Version(ctx context.Context) (string, error)
	Plugins(ctx context.Context) ([]Plugin, error)
	LoadItem(ctx context.Context, identifier string) (*LoadResult, error)
	LoadItemHandler(ctx context.Context, identifier string, audioLoaderResultHandler AudioLoadResultHandler) error
	DecodeTrack(ctx context.Context, track string) (*AudioTrackInfo, error)
	DecodeTracks(ctx context.Context, tracks []string) ([]RestAudioTrack, error)
}

type Rotation

type Rotation struct {
	RotationHz int `json:"rotationHz"`
}

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 SeekCommand

type SeekCommand struct {
	GuildID  snowflake.Snowflake `json:"guildId"`
	Position Duration            `json:"position"`
}

func (SeekCommand) MarshalJSON

func (c SeekCommand) MarshalJSON() ([]byte, error)

func (SeekCommand) Op

func (SeekCommand) Op() OpType

func (SeekCommand) OpCommand

func (SeekCommand) OpCommand()

type Severity

type Severity string
const (
	SeverityCommon     Severity = "COMMON"
	SeveritySuspicious Severity = "SUSPICIOUS"
	SeverityFault      Severity = "FAULT"
)

type SourceExtension

type SourceExtension interface {
	SourceName() string
	Encode(track AudioTrack, w io.Writer) error
	Decode(info AudioTrackInfo, r io.Reader) (AudioTrack, error)
}

type Stats

type Stats struct {
	Players        int         `json:"players"`
	PlayingPlayers int         `json:"playingPlayers"`
	Uptime         Duration    `json:"uptime"`
	Memory         Memory      `json:"memory"`
	CPU            CPU         `json:"cpu"`
	FrameStats     *FrameStats `json:"frameStats"`
}

func (Stats) Better

func (s Stats) Better(stats Stats) bool

type StatsOp

type StatsOp struct {
	Stats
}

func (StatsOp) Op

func (StatsOp) Op() OpType

type StopCommand

type StopCommand struct {
	GuildID snowflake.Snowflake `json:"guildId"`
}

func (StopCommand) MarshalJSON

func (c StopCommand) MarshalJSON() ([]byte, error)

func (StopCommand) Op

func (StopCommand) Op() OpType

func (StopCommand) OpCommand

func (StopCommand) OpCommand()

type Time added in v1.4.0

type Time struct {
	time.Time
}

func (Time) MarshalJSON added in v1.4.0

func (t Time) MarshalJSON() ([]byte, error)

func (*Time) UnmarshalJSON added in v1.4.0

func (t *Time) UnmarshalJSON(data []byte) error

type Timescale

type Timescale struct {
	Speed float32 `json:"speed"`
	Pitch float32 `json:"pitch"`
	Rate  float32 `json:"rate"`
}

type TrackEndEvent

type TrackEndEvent struct {
	GID         snowflake.Snowflake `json:"guildId"`
	TrackString string              `json:"track"`
	Reason      AudioTrackEndReason `json:"reason"`
}

func (TrackEndEvent) Event

func (TrackEndEvent) Event() EventType

func (TrackEndEvent) GuildID

func (e TrackEndEvent) GuildID() snowflake.Snowflake

func (TrackEndEvent) Op

func (TrackEndEvent) Op() OpType

func (TrackEndEvent) OpEvent

func (TrackEndEvent) OpEvent()

func (TrackEndEvent) Track

func (e TrackEndEvent) Track() string

type TrackEvent

type TrackEvent interface {
	Track() string
}

type TrackExceptionEvent

type TrackExceptionEvent struct {
	GID         snowflake.Snowflake `json:"guildId"`
	TrackString string              `json:"track"`
	Exception   FriendlyException   `json:"exception"`
}

func (TrackExceptionEvent) Event

func (TrackExceptionEvent) GuildID

func (TrackExceptionEvent) Op

func (TrackExceptionEvent) OpEvent

func (TrackExceptionEvent) OpEvent()

func (TrackExceptionEvent) Track

func (e TrackExceptionEvent) Track() string

type TrackStartEvent

type TrackStartEvent struct {
	GID         snowflake.Snowflake `json:"guildId"`
	TrackString string              `json:"track"`
}

func (TrackStartEvent) Event

func (TrackStartEvent) Event() EventType

func (TrackStartEvent) GuildID

func (e TrackStartEvent) GuildID() snowflake.Snowflake

func (TrackStartEvent) Op

func (TrackStartEvent) Op() OpType

func (TrackStartEvent) OpEvent

func (TrackStartEvent) OpEvent()

func (TrackStartEvent) Track

func (e TrackStartEvent) Track() string

type TrackStuckEvent

type TrackStuckEvent struct {
	GID         snowflake.Snowflake `json:"guildId"`
	TrackString string              `json:"track"`
	ThresholdMs Duration            `json:"threasholdMs"`
}

func (TrackStuckEvent) Event

func (TrackStuckEvent) Event() EventType

func (TrackStuckEvent) GuildID

func (e TrackStuckEvent) GuildID() snowflake.Snowflake

func (TrackStuckEvent) Op

func (TrackStuckEvent) Op() OpType

func (TrackStuckEvent) OpEvent

func (TrackStuckEvent) OpEvent()

func (TrackStuckEvent) Track

func (e TrackStuckEvent) Track() string

type Tremolo

type Tremolo struct {
	Frequency float32 `json:"frequency"`
	Depth     float32 `json:"depth"`
}

type UnknownEvent

type UnknownEvent struct {
	Data []byte
	// contains filtered or unexported fields
}

func (UnknownEvent) Event

func (e UnknownEvent) Event() EventType

func (UnknownEvent) GuildID

func (e UnknownEvent) GuildID() snowflake.Snowflake

func (UnknownEvent) MarshalJSON added in v1.4.0

func (e UnknownEvent) MarshalJSON() ([]byte, error)

func (UnknownEvent) Op

func (UnknownEvent) Op() OpType

func (UnknownEvent) OpEvent

func (UnknownEvent) OpEvent()

func (*UnknownEvent) UnmarshalJSON

func (e *UnknownEvent) UnmarshalJSON(data []byte) error

type UnknownOp

type UnknownOp struct {
	Data []byte
	// contains filtered or unexported fields
}

func (UnknownOp) MarshalJSON added in v1.4.0

func (o UnknownOp) MarshalJSON() ([]byte, error)

func (UnknownOp) Op

func (o UnknownOp) Op() OpType

func (*UnknownOp) UnmarshalJSON

func (o *UnknownOp) UnmarshalJSON(data []byte) error

type UnmarshalOp

type UnmarshalOp struct {
	Op
}

func (*UnmarshalOp) UnmarshalJSON

func (e *UnmarshalOp) UnmarshalJSON(data []byte) error

type UnmarshalOpEvent

type UnmarshalOpEvent struct {
	OpEvent
}

func (*UnmarshalOpEvent) UnmarshalJSON

func (e *UnmarshalOpEvent) UnmarshalJSON(data []byte) error

type Vibrato

type Vibrato struct {
	Frequency float32 `json:"frequency"`
	Depth     float32 `json:"depth"`
}

type VoiceServerUpdate

type VoiceServerUpdate struct {
	Token    string              `json:"token"`
	GuildID  snowflake.Snowflake `json:"guildId"`
	Endpoint *string             `json:"endpoint"`
}

type VoiceStateUpdate

type VoiceStateUpdate struct {
	GuildID   snowflake.Snowflake  `json:"guild_id"`
	ChannelID *snowflake.Snowflake `json:"channel_id"`
	SessionID string               `json:"session_id"`
}

type VoiceUpdateCommand

type VoiceUpdateCommand struct {
	GuildID   snowflake.Snowflake `json:"guildId"`
	SessionID string              `json:"sessionId"`
	Event     VoiceServerUpdate   `json:"event"`
}

func (VoiceUpdateCommand) MarshalJSON

func (c VoiceUpdateCommand) MarshalJSON() ([]byte, error)

func (VoiceUpdateCommand) Op

func (VoiceUpdateCommand) OpCommand

func (VoiceUpdateCommand) OpCommand()

type Volume

type Volume float32
var DefaultVolume Volume = 1.0

type VolumeCommand

type VolumeCommand struct {
	GuildID snowflake.Snowflake `json:"guildId"`
	Volume  int                 `json:"volume"`
}

func (VolumeCommand) MarshalJSON

func (c VolumeCommand) MarshalJSON() ([]byte, error)

func (VolumeCommand) Op

func (VolumeCommand) Op() OpType

func (VolumeCommand) OpCommand

func (VolumeCommand) OpCommand()

type WebsocketClosedEvent

type WebsocketClosedEvent struct {
	GID      snowflake.Snowflake `json:"guildId"`
	Code     int                 `json:"code"`
	Reason   string              `json:"reason"`
	ByRemote bool                `json:"byRemote"`
}

func (WebsocketClosedEvent) Event

func (WebsocketClosedEvent) GuildID

func (WebsocketClosedEvent) Op

func (WebsocketClosedEvent) OpEvent

func (WebsocketClosedEvent) OpEvent()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL