Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

aoi.js-lavalink

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aoi.js-lavalink

Package used to connect to lavalink with aoi.js easily.

  • 0.0.12
  • unpublished
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

aoi.js-lavalink is a package used to bring the functionality of lavalink to aoi.js fast and easy.

Installation

Get started by installing the latest version of aoi.js-lavalink within your project.

npm install aoi.js-lavalink@latest

Or if you're feeling lucky, install the development version with new features.

npm install github:aoi.js-lavalink

Setup

To add the functionality to your client, we have to import the lavalinkManager class.

const { AoiClient, LoadCommands } = require("aoi.js");
const { lavalinkManager } = require("aoi.js-lavalink");

const client = new AoiClient({
  token: "DISCORD BOT TOKEN",
  prefix: "DISCORD BOT PREFIX",
  intents: ["MessageContent", "Guilds", "GuildMessages", "GuildVoiceStates"],
  events: ["onInteractionCreate", "onMessage"],
  database: {
    type: "aoi.db",
    db: require("@akarui/aoi.db"),
    dbType: "KeyValue",
    tables: ["main"],
    securityKey: "a-32-characters-long-string-here",
  },
});

const lavalink = new lavalinkManager(client, {
  host: "0.0.0.0", // Server Address
  port: 0000, // Server Port
  password: "youshallnotpass", // Lavalink Server Password
  secure: false, // HTTP/HTTPS protocol
  events: ["trackStart", "trackEnd"] // Array of events that can be used.
});

// Adding events
lavalink.addEvent("trackStart", {
  code: `$log[Now playing $trackInfo[uri]!]`
});

Functions

Absolutely! Here's the comprehensive list of all the functions in a modern README.md style:

Music Player Functions

$joinVoice

Connects the bot to a specified voice channel.

$joinVoice[voiceId;returnChannel?]
  • voiceId (required)
  • returnChannel (optional, default: "false")

Example:

$joinVoice[123456789012345678;true]
$playTrack

Plays a track based on the query in the specified source.

$playTrack[query;source?;guildId?]
  • query (required)
  • source1 (optional, default: "youtube")
  • guildId (optional, default: current guild ID)

Example:

$playTrack[Despacito;youtube;123456789012345678]
$trackInfo

Retrieves information about a track in the player's queue at a specific index.

$trackInfo[index;property]
  • index (required)
  • property (required)

Example:

$trackInfo[1;title]
$loop

Sets the loop type for the player (track, queue, none).

$loop[type]
  • type (required)

Example:

$loop[track]
$loopStatus

Retrieves the current loop status of the player.

$skipTrack

Skips the currently playing track in the queue.

$skipTo

Skips to a specific track in the queue based on its index.

$skipTo[index]
  • index (required)
$seekTo

Seeks to a specific position (in milliseconds) in the currently playing track.

$seekTo[ms]
  • ms (required)
$removeTrack

Removes a track from the queue at the specified position.

$removeTrack[position]
  • position (required)
$getFilters

Retrieves filters applied to the player.

$getFilters[type]
  • type (required)
$toggleFilters

Toggles specified audio filters and returns applied filters if requested.

$toggleFilters[filterType;returnFilters]
  • filterType (required)
  • returnFilters (optional, default: "false")
$setVolume

Sets the volume of the player.

$setVolume[volume]
  • volume (required)
$shuffleQueue

Shuffles the queue of tracks.

$unShuffleQueue

Restores the original order of the queue after shuffling.

$autoPlay

Enables or disables autoplay feature for the player.

$autoPlay[source]
  • source1 (optional, default: "youtube")
$searchTrack[query;index?;format?]

Searches for tracks based on the provided query and index.

  • query (required)
  • index? (optional, default: "0")
  • format? (optional, default: false)
$pauseTrack

Pauses the currently playing track.

$resumeTrack

Resumes the paused track.

$playerStatus

Retrieves the status of the player.

Events2

Event NamesParametersDescription
nodeCreatenodeEmitted once a node gets created
nodeConnect (default3)nodeEmits when a node connects
nodeReconnect (default3)nodeEmits when a node attempts a reconnect
nodeDisconnect (default3)node, reason: { code?: number, reason?: string }Emits when a node disconnects
nodeErrornode, errorEmits when a node throws errors
nodeRawpayloadEmits every payload from a Node
playerCreateplayerEmits when a player gets created
playerDestroyplayerEmits when a player gets destroyed
queueEndplayer, track, payloadEmits when the queue End
playerMoveplayer, initChannel, newChannelEmits when the player moves from a Voice Channel to another one
playerDisconnectplayer, oldChannelEmits when the player Leaves the VC
trackStartplayer, track, payloadEmits when a track starts to play
trackEndplayer, track, payloadEmits when a track ends playing
trackStuckplayer, track, payloadEmits when a track gets stucked and skips the track
trackErrorplayer, track, payloadEmits when a track errors and skips it
socketClosedplayer, payloadEmits when a connection gets closed

Footnotes

  1. Additional Sources besides YouTube and Soundcloud require additional setup on your side. Including the editing of your application.yml and more. 2

  2. Events are used to emit Player Events, example usage of using events:

      <lavalinkInstance>.on(<event>, {
          code: `
              Your aoi.js code
          `
      });
      ```
    
    Channel, author and guild are automatically passed, meaning you can use guild, channel and author related functions without any issues.
    
  3. Executed by default, no matter what. Cannot be disabled as of now, maybe in the future as another feature. 2 3

FAQs

Package last updated on 14 Dec 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc