eris-lavalink
Links
- Documentation
- Lavalink
- eris
- lavalink.js (discord.js port)
Install
# Lavalink v2
npm install eris-lavalink
# Lavalink v1
npm install eris-lavalink@^0.1.3
Implementation
Start by creating the PlayerManager
and passing a list of nodes and optional list of regions
const PlayerManager = ; let nodes = host: 'localhost' port: 8080 region: 'eu' password: 'youshallnotpass' ; let regions = eu: 'eu' 'amsterdam' 'frankfurt' 'russia' 'hongkong' 'singapore' 'sydney' us: 'us' 'brazil'; if !clientvoiceConnections instanceof PlayerManager clientvoiceConnections = client nodes numShards: shardCount // number of shards userId: userid // the user id of the bot regions: regions defaultRegion: 'eu' ;
To resolve a track, use the Lavalink rest api
const superagent = ; { try var result = await superagent ; catch err throw err; if !result throw 'Unable play that video.'; return resultbody; // array of tracks resolved from lavalink}
To join and leave voice channels, use the Lavalink client rather than using eris.
// to get or join a channel { if !channel || !channelguild return Promise; let player = clientvoiceConnections; if player return Promise; let options = {}; if channelguildregion optionsregion = channelguildregion; return client;} // play example; // stop example
A note on pauses
When you pause a player, the player will be kept in a paused state until you explicitly call resume or the player is disconnected. Calls to play
and stop
won't clear the pause state. player.paused
can be used to check if the player is in paused state.