aoi.js-lavalink
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",
port: 0000,
password: "youshallnotpass",
secure: false,
events: ["trackStart", "trackEnd"]
});
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)source
1 (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]
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]
$seekTo
Seeks to a specific position (in milliseconds) in the currently playing track.
$seekTo[ms]
$removeTrack
Removes a track from the queue at the specified position.
$removeTrack[position]
$getFilters
Retrieves filters applied to the player.
$getFilters[type]
$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]
$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]
source
1 (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 Names | Parameters | Description |
---|
nodeCreate | node | Emitted once a node gets created |
nodeConnect (default3) | node | Emits when a node connects |
nodeReconnect (default3) | node | Emits when a node attempts a reconnect |
nodeDisconnect (default3) | node, reason: { code?: number, reason?: string } | Emits when a node disconnects |
nodeError | node, error | Emits when a node throws errors |
nodeRaw | payload | Emits every payload from a Node |
playerCreate | player | Emits when a player gets created |
playerDestroy | player | Emits when a player gets destroyed |
queueEnd | player, track, payload | Emits when the queue End |
playerMove | player, initChannel, newChannel | Emits when the player moves from a Voice Channel to another one |
playerDisconnect | player, oldChannel | Emits when the player Leaves the VC |
trackStart | player, track, payload | Emits when a track starts to play |
trackEnd | player, track, payload | Emits when a track ends playing |
trackStuck | player, track, payload | Emits when a track gets stucked and skips the track |
trackError | player, track, payload | Emits when a track errors and skips it |
socketClosed | player, payload | Emits when a connection gets closed |