Utilities
A collection of helper functions and classes used internally by Moonlink.js, including the EventEmitter, HTTP request wrapper, and track encoding/decoding logic.
While mostly used internally, these utilities can be helpful for advanced users building plugins or custom integrations.
Classes
EventEmitter
A strongly-typed, priority-based Event Emitter implementation.
Adds a listener. Options can include once and priority (higher runs first). Returns a remove function.
Adds a one-time listener.
Removes a specific listener.
Synchronously calls each of the listeners registered for the event.
Creates a child emitter that propagates events to the parent.
Structure
Manages the dependency injection and extension system for Moonlink.js classes.
Retrieves a registered structure class.
Extends an existing structure with a new class.
Functions
makeRequest(url, options)
makeRequest(url, options)#
→Promise<T | undefined>A robust HTTP/HTTPS request wrapper with built-in retry logic, timeout, and redirect handling. Used for all REST communications.
The URL to fetch.
Node.js http.RequestOptions plus optional body.
decodeTrack(encoded)
decodeTrack(encoded)#
→ITrackDecodes a Lavalink base64 track string into a usable object without making an API call. Useful for offline processing.
The base64 encoded string.
encodeTrack(track)
encodeTrack(track)#
→stringEncodes a track info object into a Lavalink base64 string.
The track info object.
validate(prop, validator, error)
Internal validation helper. Throws a TypeError with the Moonlink.js > prefix if validation fails.