lavalink

package
v3.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2023 License: Apache-2.0 Imports: 9 Imported by: 15

Documentation

Index

Constants

View Source
const (
	Millisecond Duration = 1
	Second               = 1000 * Millisecond
	Minute               = 60 * Second
	Hour                 = 60 * Minute
	Day                  = 24 * Hour
)

Variables

View Source
var DefaultFilters = []string{"volume", "equalizer", "timescale", "tremolo", "vibrato", "rotation", "karaoke", "distortion", "channelMix", "lowPass"}

Functions

This section is empty.

Types

type CPU

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

type ChannelMix

type ChannelMix struct {
	LeftToLeft   float32 `json:"leftToLeft"`
	LeftToRight  float32 `json:"leftToRight"`
	RightToLeft  float32 `json:"rightToLeft"`
	RightToRight float32 `json:"rightToRight"`
}

type Distortion

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

type Duration

type Duration int64

func (Duration) Days

func (d Duration) Days() int64

func (Duration) Hours

func (d Duration) Hours() int64

func (Duration) HoursPart

func (d Duration) HoursPart() int64

func (Duration) Milliseconds

func (d Duration) Milliseconds() int64

func (Duration) MillisecondsPart

func (d Duration) MillisecondsPart() int64

func (Duration) Minutes

func (d Duration) Minutes() int64

func (Duration) MinutesPart

func (d Duration) MinutesPart() int64

func (Duration) Seconds

func (d Duration) Seconds() int64

func (Duration) SecondsPart

func (d Duration) SecondsPart() int64

func (Duration) String

func (d Duration) String() string

type Empty

type Empty struct{}

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

func (*Equalizer) UnmarshalJSON

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

type Error

type Error struct {
	Timestamp   Timestamp `json:"timestamp"`
	Status      int       `json:"status"`
	StatusError string    `json:"error"`
	Trace       string    `json:"trace"`
	Message     string    `json:"message"`
	Path        string    `json:"path"`
}

func (Error) Error

func (e Error) Error() string

type Event

type Event interface {
	Op() Op
	Type() EventType
	GuildID() snowflake.ID
}

type EventType

type EventType string
const (
	EventTypeTrackStart      EventType = "TrackStartEvent"
	EventTypeTrackEnd        EventType = "TrackEndEvent"
	EventTypeTrackException  EventType = "TrackExceptionEvent"
	EventTypeTrackStuck      EventType = "TrackStuckEvent"
	EventTypeWebSocketClosed EventType = "WebSocketClosedEvent"
	EventTypePlayerPause     EventType = "PlayerPauseEvent"  // not actually sent by lavalink
	EventTypePlayerResume    EventType = "PlayerResumeEvent" // not actually sent by lavalink
)

type Exception

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

func (Exception) Error

func (e Exception) Error() string

type Filters

type Filters struct {
	Volume        *Volume        `json:"volume,omitempty"`
	Equalizer     *Equalizer     `json:"equalizer,omitempty"`
	Timescale     *Timescale     `json:"timescale,omitempty"`
	Tremolo       *Tremolo       `json:"tremolo,omitempty"`
	Vibrato       *Vibrato       `json:"vibrato,omitempty"`
	Rotation      *Rotation      `json:"rotation,omitempty"`
	Karaoke       *Karaoke       `json:"karaoke,omitempty"`
	Distortion    *Distortion    `json:"distortion,omitempty"`
	ChannelMix    *ChannelMix    `json:"channelMix,omitempty"`
	LowPass       *LowPass       `json:"lowPass,omitempty"`
	PluginFilters map[string]any `json:"pluginFilters,omitempty"`
}

type FrameStats

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

type Git

type Git struct {
	Branch     string    `json:"branch"`
	Commit     string    `json:"commit"`
	CommitTime Timestamp `json:"commitTime"`
}

type Info

type Info struct {
	Version        Version   `json:"version"`
	BuildTime      Timestamp `json:"buildTime"`
	Git            Git       `json:"git"`
	JVM            string    `json:"jvm"`
	Lavaplayer     string    `json:"lavaplayer"`
	SourceManagers []string  `json:"sourceManagers"`
	Filters        []string  `json:"filters"`
	Plugins        []Plugin  `json:"plugins"`
}

type Karaoke

type Karaoke struct {
	Level       float32 `json:"level"`
	MonoLevel   float32 `json:"monoLevel"`
	FilterBand  float32 `json:"filterBand"`
	FilterWidth float32 `json:"filterWidth"`
}

type LoadResult

type LoadResult struct {
	LoadType LoadType       `json:"loadType"`
	Data     LoadResultData `json:"data"`
}

func (*LoadResult) UnmarshalJSON

func (r *LoadResult) UnmarshalJSON(data []byte) error

type LoadResultData

type LoadResultData interface {
	// contains filtered or unexported methods
}

type LoadType

type LoadType string
const (
	LoadTypeTrack    LoadType = "track"
	LoadTypePlaylist LoadType = "playlist"
	LoadTypeSearch   LoadType = "search"
	LoadTypeEmpty    LoadType = "empty"
	LoadTypeError    LoadType = "error"
)

type LowPass

type LowPass struct {
	Smoothing float64 `json:"smoothing"`
}

type Memory

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

type Message

type Message interface {
	Op() Op
}

func UnmarshalMessage

func UnmarshalMessage(data []byte) (Message, error)

type Op

type Op string
const (
	OpReady        Op = "ready"
	OpStats        Op = "stats"
	OpPlayerUpdate Op = "playerUpdate"
	OpEvent        Op = "event"
)

type Player

type Player struct {
	GuildID snowflake.ID `json:"guildId"`
	Track   *Track       `json:"track"`
	Volume  int          `json:"volume"`
	Paused  bool         `json:"paused"`
	State   PlayerState  `json:"state"`
	Voice   VoiceState   `json:"voice"`
	Filters Filters      `json:"filters"`
}

type PlayerPauseEvent

type PlayerPauseEvent struct {
	GuildID_ snowflake.ID `json:"guildId"`
}

func (PlayerPauseEvent) GuildID

func (e PlayerPauseEvent) GuildID() snowflake.ID

func (PlayerPauseEvent) Op

func (PlayerPauseEvent) Op() Op

func (PlayerPauseEvent) Type

func (PlayerPauseEvent) Type() EventType

type PlayerResumeEvent

type PlayerResumeEvent struct {
	GuildID_ snowflake.ID `json:"guildId"`
}

func (PlayerResumeEvent) GuildID

func (e PlayerResumeEvent) GuildID() snowflake.ID

func (PlayerResumeEvent) Op

func (PlayerResumeEvent) Op() Op

func (PlayerResumeEvent) Type

type PlayerState

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

type PlayerUpdate

type PlayerUpdate struct {
	Track     *PlayerUpdateTrack `json:"track,omitempty"`
	Position  *Duration          `json:"position,omitempty"`
	EndTime   *Duration          `json:"endTime,omitempty"`
	Volume    *int               `json:"volume,omitempty"`
	Paused    *bool              `json:"paused,omitempty"`
	Voice     *VoiceState        `json:"voice,omitempty"`
	Filters   *Filters           `json:"filters,omitempty"`
	NoReplace bool               `json:"-"`
}

func DefaultPlayerUpdate

func DefaultPlayerUpdate() *PlayerUpdate

func (*PlayerUpdate) Apply

func (u *PlayerUpdate) Apply(opts []PlayerUpdateOpt)

type PlayerUpdateMessage

type PlayerUpdateMessage struct {
	State   PlayerState  `json:"state"`
	GuildID snowflake.ID `json:"guildId"`
}

func (PlayerUpdateMessage) Op

func (PlayerUpdateMessage) Op() Op

type PlayerUpdateOpt

type PlayerUpdateOpt func(update *PlayerUpdate)

func WithEncodedTrack

func WithEncodedTrack(encodedTrack string) PlayerUpdateOpt

func WithEndTime

func WithEndTime(endTime Duration) PlayerUpdateOpt

func WithFilters

func WithFilters(filters Filters) PlayerUpdateOpt

func WithNoReplace

func WithNoReplace(noReplace bool) PlayerUpdateOpt

func WithNullTrack

func WithNullTrack() PlayerUpdateOpt

func WithPaused

func WithPaused(paused bool) PlayerUpdateOpt

func WithPosition

func WithPosition(position Duration) PlayerUpdateOpt

func WithTrack

func WithTrack(track Track) PlayerUpdateOpt

func WithTrackIdentifier

func WithTrackIdentifier(identifier string) PlayerUpdateOpt

func WithTrackUserData

func WithTrackUserData(userData any) PlayerUpdateOpt

func WithVoice

func WithVoice(voice VoiceState) PlayerUpdateOpt

func WithVolume

func WithVolume(volume int) PlayerUpdateOpt

type PlayerUpdateTrack

type PlayerUpdateTrack struct {
	Encoded    *json.Nullable[string] `json:"encoded,omitempty"`
	Identifier *string                `json:"identifier,omitempty"`
	UserData   any                    `json:"userData,omitempty"`
}

type Players

type Players []Player

type Playlist

type Playlist struct {
	Info       PlaylistInfo `json:"info"`
	PluginInfo RawData      `json:"pluginInfo"`
	Tracks     []Track      `json:"tracks"`
}

type PlaylistInfo

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 Plugins

type Plugins []Plugin

type RawData

type RawData json.RawMessage

func (RawData) MarshalJSON

func (p RawData) MarshalJSON() ([]byte, error)

func (RawData) String

func (p RawData) String() string

func (RawData) Unmarshal

func (p RawData) Unmarshal(v any) error

func (*RawData) UnmarshalJSON

func (p *RawData) UnmarshalJSON(data []byte) error

type ReadyMessage

type ReadyMessage struct {
	Resumed   bool   `json:"resumed"`
	SessionID string `json:"sessionId"`
}

func (ReadyMessage) Op

func (ReadyMessage) Op() Op

type Rotation

type Rotation struct {
	RotationHz int `json:"rotationHz"`
}
type Search []Track

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 Session

type Session struct {
	Resuming bool `json:"resuming"`
	Timeout  int  `json:"timeout"`
}

type SessionUpdate

type SessionUpdate struct {
	Resuming *bool `json:"resuming,omitempty"`
	Timeout  *int  `json:"timeout,omitempty"`
}

type Severity

type Severity string
const (
	SeverityCommon     Severity = "common"
	SeveritySuspicious Severity = "suspicious"
	SeverityFault      Severity = "fault"
)

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 StatsMessage

type StatsMessage Stats

func (StatsMessage) Op

func (StatsMessage) Op() Op

type Timescale

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

type Timestamp

type Timestamp struct {
	time.Time
}

func Now

func Now() Timestamp

func (Timestamp) MarshalJSON

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

func (*Timestamp) UnmarshalJSON

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

type Track

type Track struct {
	Encoded    string    `json:"encoded"`
	Info       TrackInfo `json:"info"`
	PluginInfo RawData   `json:"pluginInfo"`
	UserData   RawData   `json:"userData"`
}

func (*Track) Scan

func (t *Track) Scan(value interface{}) error

func (Track) Value

func (t Track) Value() (driver.Value, error)

func (Track) WithUserData

func (t Track) WithUserData(userData any) (Track, error)

WithUserData returns a copy of the Track with the given userData.

type TrackEndEvent

type TrackEndEvent struct {
	Track    Track          `json:"track"`
	Reason   TrackEndReason `json:"reason"`
	GuildID_ snowflake.ID   `json:"guildId"`
}

func (TrackEndEvent) GuildID

func (e TrackEndEvent) GuildID() snowflake.ID

func (TrackEndEvent) Op

func (TrackEndEvent) Op() Op

func (TrackEndEvent) Type

func (TrackEndEvent) Type() EventType

type TrackEndReason

type TrackEndReason string
const (
	TrackEndReasonFinished   TrackEndReason = "finished"
	TrackEndReasonLoadFailed TrackEndReason = "loadFailed"
	TrackEndReasonStopped    TrackEndReason = "stopped"
	TrackEndReasonReplaced   TrackEndReason = "replaced"
	TrackEndReasonCleanup    TrackEndReason = "cleanup"
)

func (TrackEndReason) MayStartNext

func (e TrackEndReason) MayStartNext() bool

type TrackExceptionEvent

type TrackExceptionEvent struct {
	Track     Track        `json:"track"`
	Exception Exception    `json:"exception"`
	GuildID_  snowflake.ID `json:"guildId"`
}

func (TrackExceptionEvent) GuildID

func (e TrackExceptionEvent) GuildID() snowflake.ID

func (TrackExceptionEvent) Op

func (TrackExceptionEvent) Op() Op

func (TrackExceptionEvent) Type

type TrackInfo

type TrackInfo 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"`
	ArtworkURL *string  `json:"artworkUrl"`
	ISRC       *string  `json:"isrc"`
}

type TrackStartEvent

type TrackStartEvent struct {
	Track    Track        `json:"track"`
	GuildID_ snowflake.ID `json:"guildId"`
}

func (TrackStartEvent) GuildID

func (e TrackStartEvent) GuildID() snowflake.ID

func (TrackStartEvent) Op

func (TrackStartEvent) Op() Op

func (TrackStartEvent) Type

func (TrackStartEvent) Type() EventType

type TrackStuckEvent

type TrackStuckEvent struct {
	Track     Track        `json:"track"`
	Threshold Duration     `json:"thresholdMs"`
	GuildID_  snowflake.ID `json:"guildId"`
}

func (TrackStuckEvent) GuildID

func (e TrackStuckEvent) GuildID() snowflake.ID

func (TrackStuckEvent) Op

func (TrackStuckEvent) Op() Op

func (TrackStuckEvent) Type

func (TrackStuckEvent) Type() EventType

type Tremolo

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

type UnknownEvent

type UnknownEvent struct {
	Type_    EventType       `json:"type"`
	GuildID_ snowflake.ID    `json:"guildId"`
	Data     json.RawMessage `json:"-"`
}

func (UnknownEvent) GuildID

func (e UnknownEvent) GuildID() snowflake.ID

func (UnknownEvent) MarshalJSON

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

func (UnknownEvent) Op

func (UnknownEvent) Op() Op

func (UnknownEvent) Type

func (e UnknownEvent) Type() EventType

func (*UnknownEvent) UnmarshalJSON

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

type UnknownMessage

type UnknownMessage struct {
	Op_  Op              `json:"op"`
	Data json.RawMessage `json:"-"`
}

func (UnknownMessage) MarshalJSON

func (m UnknownMessage) MarshalJSON() ([]byte, error)

func (UnknownMessage) Op

func (m UnknownMessage) Op() Op

func (*UnknownMessage) UnmarshalJSON

func (m *UnknownMessage) UnmarshalJSON(data []byte) error

type Version

type Version struct {
	Semver     string `json:"semver"`
	Major      int    `json:"major"`
	Minor      int    `json:"minor"`
	Patch      int    `json:"patch"`
	PreRelease string `json:"preRelease"`
}

type Vibrato

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

type VoiceState

type VoiceState struct {
	Token     string `json:"token"`
	Endpoint  string `json:"endpoint"`
	SessionID string `json:"sessionId"`
}

type Volume

type Volume float32

type WebSocketClosedEvent

type WebSocketClosedEvent struct {
	Code     int          `json:"code"`
	Reason   string       `json:"reason"`
	ByRemote bool         `json:"byRemote"`
	GuildID_ snowflake.ID `json:"guildId"`
}

func (WebSocketClosedEvent) GuildID

func (e WebSocketClosedEvent) GuildID() snowflake.ID

func (WebSocketClosedEvent) Op

func (WebSocketClosedEvent) Op() Op

func (WebSocketClosedEvent) Type

Jump to

Keyboard shortcuts

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