npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

aoijs.lavalink

v4.12.0

Published

A package for integrating Lavalink with Aoi.js to enable music streaming in Discord bots.

Downloads

198

Readme

aoijs.lavalink

A package for integrating Lavalink with Aoi.js to enable music streaming in Discord bots.


Installation

stable version:

npm install aoijs.lavalink

development version:

npm install tyowk/aoijs.lavalink

Setup

The setup is used to initialize the bot client and configure the Lavalink music system. aoi.js is the main client framework, and aoijs.lavalink is an integration that allows you to connect to a Lavalink server to stream music.

const { AoiClient } = require('aoi.js');
const { Manager } = require('aoijs.lavalink');

const client = new AoiClient({ /* ••• */ });

const voice = new Manager(client, {
    nodes: [{
        name: 'my lavalink node',
        host: 'yourdomain.com',
        port: 0000,
        auth: 'youshallnotpass',
        secure: false
    }]
});
new Manager(<AoiClient>, {
    nodes: [{
        name: string,
        host: string,
        port: number,
        auth: string,
        secure: boolean
    },{ /* ••• */ }],

    maxQueueSize?: number,
    maxPlaylistSize?: number,
    maxHistorySize?: number,
    searchEngine?: string,
    debug?: boolean,
    defaultVolume?: number,
    maxVolume?: number,
    noLimitVolume?: boolean,
    deleteNowPlaying?: boolean,
    playlist?: {
        enable: boolean,
        table: string,
        database?: unknown,
        maxSongs?: number,
        maxPlaylist?: number
    }
});

Default Options

| Option | Type | Default | Description | | ----------------- | ----------------------------------- | ------- | ------------------------------------------------------------------------------- | | nodes | Node[] | - | (see below) | | playlist? | Playlist | - | (see below) | | maxQueueSize? | number | 100 | Maximum number of tracks that can be queued for playback. | | maxPlaylistSize? | number | 100 | Maximum number of tracks that can be in a playlist. | | maxHistorySize? | number | 100 | Maximum number of tracks that can be saved in the history. | | searchEngine? | string | youtube | Default search engine. You can set this to 'soundcloud' or 'spotify' or others. | | debug? | boolean | false | Whether to enable debug logs for the music client. | | defaultVolume? | number | 100 | Set default volume when the player created. | | maxVolume? | number | 200 | Maximum volume player can handle. | | noLimitVolume? | boolean | false | Whether to enable no limit volume (not recommended). | | deleteNowPlaying? | number | 200 | Whether to enable auto-delete now playing message when track ends. |

Node Options

| Option | Type | Description | | ------ | --------- | ------------------------------------------------------------------------ | | name? | string | custom name for the Lavalink node (can be any string) | | host | string | URL to your Lavalink node. Replace with your actual Lavalink server URL. | | port | number | Your lavalink server port. | | auth | boolean | Authentication password for the Lavalink node. | | secure | boolean | Set to true if your Lavalink server uses SSL/TLS (HTTPS). |

Playlist Options

| Option | Type | Description | | ------------ | --------- | --------------------------------------------------------------------- | | enable | boolean | Whether to enable playlist feature or not. | | table | string | Name of the database table to store playlists. | | maxSongs? | number | Maximum number of songs allowed in a single playlist. (default is 20) | | maxPlaylist? | number | Maximum number of playlist allowed per user. (default is 10) | | database? | unknown | Reference to the database instance |

see here for more client options.


Playlist

This feature allows users to create and manage playlists, enhancing their music experience.

See the documentation for more information and guides


Events

You can listen to various events such as when a track starts, when the player is paused, etc., and respond to them with custom code.

const voice = new Manager(<AoiClient>, { /* ••• */ });

voice.<eventName>({
    channel: '$channelId',
    code: `$songInfo[title]`
});

This section will list all events.

  1. trackStart: Triggered when a track begins playing on the Lavalink node. This marks the start of the track’s playback.
  2. trackEnd: Occurs when a track finishes playing. This can happen when the track ends naturally or when it is stopped before completion.
  3. trackStuck: Triggered when a track gets stuck due to an error or issue like buffering or network problems, preventing it from progressing.
  4. trackPaused: Occurs when the playback of the track is paused, either manually or automatically due to external reasons (e.g., user interaction or system settings).
  5. trackResumed: Triggered when a previously paused track starts playing again, either after manual resumption or an automatic action.
  6. queueStart: Occurs when a new queue of tracks starts to be processed and played by the Lavalink node. This is the beginning of playback for a set of tracks.
  7. queueEnd: Triggered when the track queue finishes playing all the tracks. This event marks the end of the queue’s playback.
  8. nodeConnect: Triggered when a successful connection is established with a Lavalink node. The player can now interact with the node for streaming and playback.
  9. nodeReconnect: Occurs when a previously disconnected Lavalink node is reconnected. This could happen automatically after a temporary loss of connection.
  10. nodeDisconnect: This event occurs when the Lavalink node disconnects, either intentionally or due to a failure or disconnection.
  11. nodeError: Triggered when an error occurs with the Lavalink node, such as a failure in audio processing, network issues, or other internal node errors.
  12. nodeDestroy: Occurs when a Lavalink node is destroyed or cleaned up. This usually happens when the node is no longer needed or is being replaced.
  13. nodeDebug: This event provides debugging information about the Lavalink node. It’s often used to log detailed information about the node’s state for troubleshooting.
  14. socketClosed: Triggered when the socket connection between the client and Lavalink node is closed, either due to an error, timeout, or manual disconnection.
  15. playerCreate: Occurs when a new player instance is created. This happens when a new user starts playing music or a new player session is initialized.
  16. playerDestroy: Triggered when a player instance is destroyed. This occurs when a player session ends or is no longer needed.
  17. playerException: Occurs when an error or exception happens within the player, such as invalid operations, failed track loading, or playback errors.
  18. playerUpdate: Triggered when there’s an update to the player’s state, such as changes to the volume, track, or other settings that affect playback.
  19. playerMove: Triggered when the player moves to a different voice channel. This happens when the player switches its active voice connection, typically in response to a user command or action.

Handlers

const voice = new Manager(client, { /* ••• */ });

// Load custom music event handlers from a directory. 'false' disables debug logs.
voice.loadVoiceEvents('./voice/', false);

Example Event File (in /voice/trackStart.js):

module.exports = [{
    channel: '$channelId',
    type: 'trackStart',
    code: `$songInfo[title]`
}];

Notice

  • Reading Functions: Currently aoi.js reads $ functions from bottom to top.

Documentation Support Server