Skip to content
SebasLoadJsPublic

About

MoonLink.js is a simple package for lavalink client, perfect for you to create your discord bot with songs, and very simple and easy to use.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

NyxLink

NyxLink

For the music bots you haven't built yet.
A TypeScript client for Lavalink v4 & NodeLink.

npm release Monthly npm downloads Development CI Node.js 22.12+ OSL-3.0

Documentation · Getting started · Backends · Aurora · History · Español

Animated waveform


A small animated night spirit waving hello

Hey, you found NyxLink! ✨

Maybe you're building your first music bot. Maybe you've already spent a night debugging a player that refused to resume after a node disconnected. Or maybe you want to build an entire music experience, not just a /play command.

NyxLink sits between your Discord application and the audio server. It takes care of the client-side pieces: connecting nodes, tracking players, resolving tracks, managing queues, coordinating recovery and giving you access to the features your backend actually supports.

Your music bot is still yours. Let's make the plumbing a little less distracting.

Why another audio client?

Lavalink and NodeLink are not interchangeable in every detail. A player may support the common v4 protocol but expose different sources, plugins, filters, metadata and native extensions.

We wanted one client that understands those differences instead of pretending they don't exist. NyxLink keeps a common API for everyday playback, exposes backend-specific operations when needed, and makes compatibility an explicit part of routing and recovery.

NyxLink began with Moonlink.js. The upstream project is now archived; NyxLink is independently maintained by SebasLoadJs, with its own architecture, identity and release lifecycle. The original authors retain their copyright and attribution.

A curious night spirit examining two audio signals
Navigate the guide

What can it do?

  • 🎧 Playback lifecycle — queues, pause, resume, skip, seek, volume acknowledgement, repeat and autoplay.
  • 🔎 Discovery — text and URL search, provider-specific discovery, metadata fallback, timeouts, cancellation and bounded caching.
  • 🔀 Multiple nodes — selection by eligibility, capabilities, load, region, source health and optional weighted cost.
  • 🛟 Recovery — session resumption, circuit breakers, migration, rollback and cleanup.
  • 🎚️ Audio controls — common filters, native NodeLink extensions and Lavalink plugin effects.
  • 💾 Persistent state — in-memory, local and Redis stores, versioned snapshots and distributed guild ownership.
  • 🌌 Aurora — structured logging, terminal presentation, an optional inspector and host-managed OpenTelemetry.
  • 🧩 Extensions — typed lifecycle hooks and backend-aware operations without imposing a particular Discord bot architecture.

NyxLink does not decode audio, operate its own music catalogue or replace your audio server. It communicates with external engines over REST and WebSocket.

Two engines, one client

NyxLink routes Discord applications to Lavalink or NodeLink with optional Redis and Aurora

Lavalink NodeLink
Protocol v4 REST / WS v4-compatible REST / WS
Core player controls Native Native
Extended discovery LavaSearch + provider plugins Native search modifiers
Track metadata LavaSrc plugin Holo Tracks, native pluginInfo
Lyrics LavaLyrics plugin Native lyrics and subscriptions
DSP filters Common filters + LavaDSPX Common and native extended filters
SponsorBlock Plugin Native extension
Crossfade, AutoMix, audio layers Not assumed Native when supported
Stream and format endpoints Not assumed Revision/configuration dependent
Node selection and recovery NyxLink NyxLink

Important

Capabilities are not determined by product names alone. A missing plugin, disabled endpoint or older node can make an operation unavailable. NyxLink exposes capability observations and typed errors rather than silently translating unsupported operations.

The tested server profiles include Lavalink 4.2.2 and pinned baseline/modern NodeLink revisions. See the compatibility record for exact versions, plugin scope and limitations.

Let's build something

Animated night spirit listening to music and celebrating

From an empty project to your first track

You'll need Node.js 22.12 or newer, a Discord application, and an accessible Lavalink v4 or NodeLink server. The SDK is not the audio server, so start your chosen engine first.

New to audio nodes? Start with Lavalink's documentation or NodeLink's documentation.

Install

npm install nyxlink discord.js@14
pnpm, Yarn, Bun and release channels
pnpm add nyxlink
yarn add nyxlink
bun add nyxlink
npm channel Command
Stable npm install nyxlink
Release candidate npm install nyxlink@next
Published development npm install nyxlink@dev

Bun is listed as a package manager; this does not certify the Bun runtime. The library's runtime requirement is Node.js. This branch preserves the 5.3 stable source. The development line targets 5.4 separately; registry badges report published versions, not branch manifests.

Configure your bot

Set the environment variables BOT_TOKEN and AUDIO_NODE_PASSWORD. The host and port in this example are placeholders; use your server's actual address, password and TLS configuration.

const { Client, GatewayIntentBits } = require('discord.js');
const { Manager, Connectors } = require('nyxlink');

const token = process.env.BOT_TOKEN;
const password = process.env.AUDIO_NODE_PASSWORD;

if (!token || !password) {
  throw new Error('Set BOT_TOKEN and AUDIO_NODE_PASSWORD.');
}

const client = new Client({
  intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildVoiceStates],
});

const nodes = [{
  identifier: 'main',
  host: 'localhost',
  port: 3000,
  password,
  secure: false,
}];

const manager = new Manager({
  nodes,
  options: {
    database: { type: 'memory' },
    resume: false,
  },
});

manager.use(new Connectors.DiscordJs(), client);

manager.on('nodeReady', node => {
  console.log(`Node connected: ${node.identifier}`);
});

manager.on('nodeError', (node, error) => {
  console.error(`[${node.identifier}] ${error.message}`);
});

manager.on('trackStart', (player, track) => {
  console.log(`[${player.guildId}] Playing: ${track.title}`);
});

client.login(token).catch(console.error);

Register the Discord connector before login. Wait for nodeReady before attempting commands that need a usable node session.

Tip

Prefer TypeScript? The root package ships declarations and can be imported from ESM or CommonJS. See the TypeScript example and the JavaScript example.

Your first playback command

async function play(guildId, voiceChannelId, query, requester) {
  const result = await manager.search({
    query,
    requester,
    signal: AbortSignal.timeout(10000),
  });

  if (!result.tracks.length) {
    throw new Error(result.exception?.message ?? 'No tracks found.');
  }

  const player = manager.players.get(guildId)
    ?? manager.players.create({ guildId, voiceChannelId, volume: 50 });

  if (player.voiceChannelId !== voiceChannelId) {
    throw new Error('The player is connected to a different voice channel.');
  }

  player.queue.add(result.tracks[0]);

  if (!player.playing && !player.paused && !(await player.play())) {
    throw new Error('The node did not acknowledge playback.');
  }

  return player;
}

This handler assumes the application has already checked permissions and obtained the user's voice channel ID. The application still owns its commands and Discord UI.

Following a track through NyxLink

Here's the path of a request from the moment someone types a song name to the moment the audio server reports playback.

flowchart TD
    A[Discord command] --> B[Manager.search]
    B --> C[Eligible node selection]
    C --> D[Backend loadtracks REST API]
    D --> E[Track metadata and encoded track]
    E --> F[Player queue]
    F --> G[Player.play]
    G --> H[Voice and player update]
    H --> I[Audio server playback pipeline]
    I --> J[Discord voice]
    I --> K[WebSocket events]
    K --> L[NyxLink state and application events]
Loading
  1. Discover. The Manager selects an eligible node and sends the search request. Provider-specific discovery can also return artists, albums and playlists that are not themselves playable tracks.
  2. Resolve. NyxLink validates the response and keeps the track's original encoded data and plugin metadata. When moving to another backend, resolution follows the destination's supported sources rather than assuming the old encoding is portable.
  3. Queue. The Player owns a queue and exposes explicit playback operations. Commands remain ordered and old operations cannot overwrite a newer playback intent.
  4. Play. The client coordinates player updates and voice state through the backend API. The server owns decoding, processing and packet delivery.
  5. Observe. WebSocket events and player state inform your bot's user interface, storage and diagnostics. A REST acknowledgement is not an audible playback measurement.
  6. Recover. If a node fails, the SDK selects an eligible destination, prepares compatible state and commits migration only after the required acknowledgements.

Public API · Node selection · Backend contracts

Search, queues and playback

Discovery and metadata

const result = await manager.search({
  query: 'Daft Punk',
  source: 'spotify',
  signal: AbortSignal.timeout(10000),
});

const track = result.tracks[0];
const lava = track?.getLavaSrcMetadata();
const holo = track?.getHoloMetadata();
const collection = result.getLavaSrcMetadata();

The source must be supported by the selected node. International source prefixes available in the inspected NodeLink contracts include azsearch (Amazon Music), lfsearch (Last.fm), shsearch (Shazam) and slsearch (Songlink). Discovery and link resolution do not necessarily provide playable audio.

Playback controls

Operation Method
Pause / resume await player.pause() / await player.resume()
Skip await player.skip()
Seek to one minute await player.seek(60000)
Confirm volume await player.setVolumeAsync(50)
Repeat player.setLoop('track'), 'queue', 'off'
Autoplay player.setAutoPlay(true)
Stop / destroy await player.stop() / await player.destroy()
Transfer await player.transferNode(identifier)

For playlists, enqueue result.tracks rather than only the first track. Check operation return values and errors before announcing success to your users.

NodeLink beyond playback

NodeLink's native extensions are intentionally exposed as backend-specific operations.

Lyrics and source health

const health = await node.getSourceHealth();

const lyrics = await node.loadLyrics(track, {
  lang: 'es',
  type: 'lyrics',
});

Lyrics and captions depend on enabled providers. Source health is an observation with a freshness window, not a permanent declaration that a provider works.

Crossfade, AutoMix and mixing

  • player.setCrossfade(options) configures the native transition.
  • player.setNextTrack(track) prepares an explicit next track.
  • player.setQueuePreload({ enabled: true, leadMs: 35000 }) enables queue-backed preload.
  • player.addMix(track, { volume: 0.25 }), getMixes(), updateMixVolume() and removeMix() manage native audio layers.

AutoMix analysis belongs to the server; NyxLink does not create its own mixing engine. Audio layer recovery is opt-in and can restart layers rather than preserving their exact position. See mixer semantics.

Formats and streams

const formats = await node.getStreamFormats(track);
const { stream, headers, statusCode } = await node.loadSourceStream(track, {
  range: 'bytes=0-65535',
});

// Consume the stream, or destroy it when no longer needed.

Source passthrough and decoded PCM are different transports. An HTTP 200 response does not establish that a Range was honored. The known HTTP WAV seek incident is tracked in the seek investigation.

The next step: richer media

The development line is exploring richer provider metadata, timed lyrics, visualization and analysis. These experimental contracts are not part of the 5.3.0 npm release. Follow the development integration audit for their status.

Lavalink and its plugins

Lavalink remains a first-class backend. Plugin features use their own contracts instead of being treated as equivalent to unrelated NodeLink endpoints.

LavaSearch and LavaSrc

if (node.backend?.supports('lavasearch')) {
  const results = await node.loadSearch('spsearch:Architects', {
    types: ['track', 'album', 'artist', 'playlist', 'text'],
    signal: AbortSignal.timeout(10000),
  });
}

Lyrics and DSP

const lyrics = await node.getLavaLyrics(track, {
  skipTrackSource: false,
});

if (player.node.backend?.supports('lavadspx')) {
  player.filters.setLavaDSPX('high-pass', { cutoffFrequency: 80 });
  await player.filters.apply();
}

Plugin names, installed versions and provider configuration determine availability. Read Lavalink support for SponsorBlock, LavaLyrics, LavaSrc metadata and filter semantics.

When a node goes away

Playback state and backend-specific capabilities are different things. A destination might support ordinary playback while not supporting the current source's mixer, filters or native transitions.

NyxLink's routing checks eligibility before ranking nodes, retains compatible playback state, suspends unsupported preferences and reports migration progress. On a failed transaction, the old player is not discarded just because a destination was selected.

const manager = new Manager({
  nodes,
  options: {
    database: { type: 'memory' },
    resume: true,
    search: {
      defaultPlatform: 'youtube',
      timeoutMs: 10000,
      resultLimit: 10,
      fallbackPlatforms: ['soundcloud'],
      cache: { ttlMs: 30000, maxEntries: 100 },
    },
    node: {
      selectionStrategy: 'leastLoad',
      autoMovePlayers: true,
      failover: { maxAttempts: 2, retryDelayMs: 250 },
      circuitBreaker: {
        failureThreshold: 3,
        windowMs: 30000,
        cooldownMs: 30000,
      },
    },
  },
});

For callers that need a particular backend or capability:

const destination = manager.nodes.findNode({
  backend: 'nodelink',
  requiredCapabilities: ['nextTrack'],
  region: 'eu',
  preferSource: 'youtube',
});

The selection does not initiate a migration by itself. It returns an eligible node or no match. Distributed applications can use Redis ownership and versioned player snapshots; see Redis and node selection.

Meet Aurora

Aurora structured event pipeline and optional outputs

Logs should help you understand the music system, not drown you in it. Aurora organizes SDK events into one canonical Pino pipeline and lets the host choose the presentation and telemetry destinations.

The core is silent by default. Consola, Pino Pretty, Ink and OpenTelemetry are selected explicitly rather than starting terminal renderers or telemetry exporters at import time.

import { Manager } from 'nyxlink';
import { createAuroraPipeline } from 'nyxlink/aurora';

const aurora = createAuroraPipeline({
  format: 'aurora',
  level: 'info',
});

const manager = new Manager({
  nodes,
  options: {
    logging: { level: aurora.level, target: aurora.target },
  },
});

aurora.banner(manager);
// Register the Discord connector and use the manager in your application.

// On application shutdown:
await manager.shutdown();
await aurora.close();
All Aurora entry points and optional tools
Entry What it gives you
nyxlink/aurora Aurora, Pretty, JSON, Custom and Silent outputs
nyxlink/aurora/bootstrap Startup and readiness observation
nyxlink/aurora/diagnostics Music snapshots and incident tables
nyxlink/aurora/inspector Read-only interactive Ink inspector
nyxlink/aurora/file Bounded private NDJSON destination
nyxlink/aurora/otel Event/span correlation
nyxlink/aurora/sdk Explicit host SDK and telemetry lifecycle

Pino handles canonical events; Consola, Chalk, Figlet, gradient-string, Boxen and related tools provide optional terminal presentation. Ink/React power the optional inspector. OpenTelemetry is host-owned.

Install the dependencies for the profile you actually use from Aurora installation. The root SDK does not require React or the optional terminal packages.

Try the demonstration after installing its required optional dependencies:

npx nyxlink-aurora --scenario all --snapshot

The scenario is simulated. It illustrates diagnostic output, not a measurement of a live bot.

Dependencies and runtime

NyxLink keeps the root runtime small in scope and leaves optional presentation/telemetry to the application.

Layer Packages
Core Pino, Consola
Formatting Pino Pretty, Chalk, Figlet, gradient-string, Boxen
Terminal UI Ink, React, Fuse.js, Listr2, Ora and terminal utilities
Observability OpenTelemetry API, SDK and optional OTLP exporters
Development TypeScript, Node test runner, Tinybench

The full pinned dependency inventory is in package.json and pnpm-lock.yaml. Optional dependencies are not all installed automatically for consumers.

Events

Your bot decides what to do with playback events — update a now-playing message, display lyrics, update a web player or record an operational metric.

manager.on('nodeReady', node => {
  console.log('Ready:', node.identifier);
});

manager.on('trackStart', (player, track) => {
  console.log(player.guildId, track.title);
});

manager.on('playerNodeFailover', (player, report) => {
  // Use the report to inspect migration and suspended features.
  console.log(player.guildId, report);
});
Event Meaning
nodeReady, nodeResume, nodeDisconnect Node lifecycle
trackStart, trackEnd, trackException Track lifecycle
queueEnd, autoPlayed Queue and autoplay
playerNodeFailover, playerDestroy Recovery and cleanup
mixStart, mixEnd Native audio layers
lyricsFound, lyricsLine, lyricsNotFound Native lyric events
sponsorBlockEvent Normalized segments and chapters

Full signatures: IManagerEvents and generated declarations.

What we actually test

Recorded CI: 1127 tests, zero failures, 85.64 percent lines, 302 exports, 21 package checks; six proposal module tests

Recorded checkpoints, not claims about every later commit:

  • Node.js 22 and 24: 1,127 unit/contract tests, zero failures; public declarations and 21 package checks passed on e41d7db.
  • CodeQL, Redis and pinned local backend tests passed on that revision.
  • All six exact NodeLink proposal module tests passed on 37fa079.
  • Real voice, source credentials, audible AutoMix transitions and release-specific acceptance remain separate.

Live CI status · Acceptance record

Git history

NyxLink preserves its inherited Moonlink history, early development packages and the 5.3 stabilization. The graph also shows the later development lineage on dev.

Selected actual Git commits and their parent connections

Milestone Date
Inherited lineage and legacy tags Historical
v0.1.0-dev.2 03 Nov 2026
v5.3.0-rc.1 24 Nov 2026
v5.3.0-rc.2 25 Nov 2026
v5.3.0 25 Nov 2026
5.4 development starts 26 Nov 2026

The graph is a selected, dated snapshot of real parent links. Older inherited tags are not proof that NyxLink published packages with those same version numbers.

All commits · Network graph · Compare stable to dev · Changelog

Documentation and development

Guide Start here
SDK API reference · Generated declarations
Examples JavaScript · TypeScript
Backends NodeLink · Lavalink · Compatibility
Recovery Node selection · Redis
Extensions Mixer · Extension lifecycle
Aurora Installation · Logging · Observability
Migration From Moonlink
Release 5.4 runbook · Changelog

To build the stable source checkout:

git clone https://github.com/SebasLoadJs/NyxLink.git
cd NyxLink
corepack pnpm install --frozen-lockfile
pnpm run build
pnpm run typecheck:strict

The full development and regression laboratory lives on dev. The stable branch is a clean maintenance snapshot; historical immutable release tags preserve their original contents. Future npm release artifacts are tested in the development workflow before publication.

The people behind the project

SebasLoadJs GitHub avatar SebasLoadJs
NyxLink maintainer.
1Lucas1apk GitHub avatar 1Lucas1apk & Moonlink contributors
Original project lineage and upstream foundations.

Contributors, including inherited project history

Contributor visualization includes inherited Git history; it does not imply active NyxLink maintainership.

Project growth

NyxLink GitHub star history

License

NyxLink is distributed under the Open Software License 3.0, derived from Moonlink.js. NOTICE.md records upstream attribution and modifications.

NyxLink night spirit waving goodbye

Now go build something worth listening to.
Thanks for visiting NyxLink.

About

MoonLink.js is a simple package for lavalink client, perfect for you to create your discord bot with songs, and very simple and easy to use.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages