Sonatica
The Sonatica class represents the main functionality of the Sonatica
Constructor
new Sonatica(options: ManagerOptions)Options
| Options | Type | Description |
|---|---|---|
autoPlay | boolean | Indicates if songs should automatically play. |
autoResume | boolean | Automatically resume players. |
autoMove | boolean | Move players to other node if node going down. |
cliendId | string | The ID of the client. |
redisUrl | string | The URL of the redis server. used for auto resume. |
cliendName | string | The name of the client. |
nodes | array | The list of NodeOptions. |
shards | number | The number of shard count. |
defaultSearchPlatform | string | The default search platform. |
Properties
| Property | Type | Description |
|---|---|---|
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
| Parameter | Type |
|---|---|
id | string |
payload | Payload |
sorter(nodes: Collection<string, Node>): Collection<string, Node>
Function to sort nodes.
Returns:
Collection<string, Node>
| Parameter | Type |
|---|---|
nodes | Collection<string, Node> |
Overview
Events
• nodeCreate
Emitted when a Node is created.
Parameter Type node Node
• nodeDestroy
Emitted when a Node is destroyed.
Parameter Type node Node
• nodeConnect
Emitted when a Node connects.
Parameter Type node Node
• nodeReconnect
Emitted when a Node reconnects.
Parameter Type node Node
• nodeDisconnect
Emitted when a Node disconnects.
Parameter Type node Node reason { code: number , reason: string }
• nodeError
Emitted when a Node has an error.
Parameter Type node Node error Error
• nodeRaw
Emitted whenever any Lavalink event is received.
Parameter Type payload unknown
• nodeSwitch
Emitted when a Node is switched.
Parameter Type player Player oldNode Node newNode Node
• playerCreate
Emitted when a player is created.
Parameter Type player Player
• playerDestroy
Emitted when a player is destroyed.
Parameter Type player Player
• queueEnd
Emitted when a player queue ends.
Parameter Type player Player
• playerMove
Emitted when a player is moved to a new voice channel.
Parameter Type player Player oldChannel string newChannel string
• trackStart
Emitted when a track starts.
Parameter Type player Player track Track payload TrackStartEvent
• trackEnd
Emitted when a track ends.
Parameter Type player Player track Track payload TrackEndEvent
• trackStuck
Emitted when a track gets stuck during playback.
Parameter Type player Player track Track payload TrackStuckEvent
• trackError
Emitted when a track has an error during playback.
Parameter Type player Player track Track payload TrackExceptionEvent
• socketClosed
Emitted when a voice connection is closed.
Parameter Type player Player payload WebSocketClosedEvent
Properties
• nodes
The map of nodes.
Type Value Collection<string, Node> new Collection<string, Node>()
• options
The options that were set.
Type ManagerOptions
• players
The map of players.
Type Value Collection<string, Player> new Collection<string, Player>()
Methods
• create()
Creates a player or returns one if it already exists.
Returns: Player
Parameter Type options PlayerOptions
• createNode()
Creates a node or returns one if it already exists.
Returns: Node
Parameter Type options NodeOptions
• decodeTrack()
Decodes the base64 encoded track and returns a TrackData.
Returns: Promise<TrackData>
Parameter Type track string
• decodeTracks()
Decodes the base64 encoded tracks and returns a TrackData array.
Returns: Promise<TrackData
[]>
Parameter Type tracks string []
• destroy()
Destroys a player if it exists.
Returns:
void
Parameter Type guild string
• destroyNode()
Destroys a node if it exists.
Returns:
void
Parameter Type identifier string
• get()
Returns a player or undefined if it does not exist.
Returns: Player |
undefined
Parameter Type guild string
• init()
Initiates the Manager.
Returns:
this
Parameter Type clientId string
• search()
Searches the enabled sources based off the URL or the
sourceproperty.Returns: Promise<SearchResult>
Parameter Type query SearchQuery Optionalrequesterunknown
• updateVoiceState()
Sends voice data to the Lavalink server.
Returns:
void
Parameter Type data VoicePacket