Skip to content

Sonatica

The Sonatica class represents the main functionality of the Sonatica

Constructor

ts
new Sonatica(options: ManagerOptions)

Options

OptionsTypeDescription
autoPlaybooleanIndicates if songs should automatically play.
autoResumebooleanAutomatically resume players.
autoMovebooleanMove players to other node if node going down.
cliendIdstringThe ID of the client.
redisUrlstringThe URL of the redis server. used for auto resume.
cliendNamestringThe name of the client.
nodesarrayThe list of NodeOptions.
shardsnumberThe number of shard count.
defaultSearchPlatformstringThe default search platform.

Properties

PropertyTypeDescription
nodes(Collection<string, Node>)The collection of nodes in the system.
players(Collection<string, Player>)The collection of players in the system.

Methods

send(id: string, payload: Payload): void

Function to send data to the websocket.

Returns: void

ParameterType
idstring
payloadPayload

sorter(nodes: Collection<string, Node>): Collection<string, Node>

Function to sort nodes.

Returns: Collection<string, Node>

ParameterType
nodesCollection<string, Node>

Overview

PropertiesMethodsEvents
nodescreatenodeCreate
optionscreateNodenodeDestroy
playersdecodeTracknodeConnect
decodeTracksnodeReconnect
destroynodeDisconnect
destroyNodenodeError
getnodeRaw
initnodeSwitch
searchplayerCreate
updateVoiceStateplayerDestroy
queueEnd
playerMove
trackStart
trackEnd
trackStuck
trackError
socketClosed

Events

• nodeCreate

Emitted when a Node is created.

ParameterType
nodeNode

• nodeDestroy

Emitted when a Node is destroyed.

ParameterType
nodeNode

• nodeConnect

Emitted when a Node connects.

ParameterType
nodeNode

• nodeReconnect

Emitted when a Node reconnects.

ParameterType
nodeNode

• nodeDisconnect

Emitted when a Node disconnects.

ParameterType
nodeNode
reason{ code: number , reason: string }

• nodeError

Emitted when a Node has an error.

ParameterType
nodeNode
errorError

• nodeRaw

Emitted whenever any Lavalink event is received.

ParameterType
payloadunknown

• nodeSwitch

Emitted when a Node is switched.

ParameterType
playerPlayer
oldNodeNode
newNodeNode

• playerCreate

Emitted when a player is created.

ParameterType
playerPlayer

• playerDestroy

Emitted when a player is destroyed.

ParameterType
playerPlayer

• queueEnd

Emitted when a player queue ends.

ParameterType
playerPlayer

• playerMove

Emitted when a player is moved to a new voice channel.

ParameterType
playerPlayer
oldChannelstring
newChannelstring

• trackStart

Emitted when a track starts.

ParameterType
playerPlayer
trackTrack
payloadTrackStartEvent

• trackEnd

Emitted when a track ends.

ParameterType
playerPlayer
trackTrack
payloadTrackEndEvent

• trackStuck

Emitted when a track gets stuck during playback.

ParameterType
playerPlayer
trackTrack
payloadTrackStuckEvent

• trackError

Emitted when a track has an error during playback.

ParameterType
playerPlayer
trackTrack
payloadTrackExceptionEvent

• socketClosed

Emitted when a voice connection is closed.

ParameterType
playerPlayer
payloadWebSocketClosedEvent

Properties

• nodes

The map of nodes.

TypeValue
Collection<string, Node>new Collection<string, Node>()

• options

The options that were set.

Type
ManagerOptions

• players

The map of players.

TypeValue
Collection<string, Player>new Collection<string, Player>()

Methods

• create()

Creates a player or returns one if it already exists.

Returns: Player

ParameterType
optionsPlayerOptions

• createNode()

Creates a node or returns one if it already exists.

Returns: Node

ParameterType
optionsNodeOptions

• decodeTrack()

Decodes the base64 encoded track and returns a TrackData.

Returns: Promise<TrackData>

ParameterType
trackstring

• decodeTracks()

Decodes the base64 encoded tracks and returns a TrackData array.

Returns: Promise<TrackData[]>

ParameterType
tracksstring[]

• destroy()

Destroys a player if it exists.

Returns: void

ParameterType
guildstring

• destroyNode()

Destroys a node if it exists.

Returns: void

ParameterType
identifierstring

• get()

Returns a player or undefined if it does not exist.

Returns: Player | undefined

ParameterType
guildstring

• init()

Initiates the Manager.

Returns: this

ParameterType
clientIdstring

Searches the enabled sources based off the URL or the source property.

Returns: Promise<SearchResult>

ParameterType
querySearchQuery
Optional requesterunknown

• updateVoiceState()

Sends voice data to the Lavalink server.

Returns: void

ParameterType
dataVoicePacket