Common Usage
This content is for the 3.4.2 version. Switch to the latest version for up-to-date documentation.
Search and Join a Channel
Get a Lavalink node that you are connected to, which was specified when creating the Shoukaku instance.
const node = shoukaku.getNode();if (!node) return;
Search for a track, here we are searching via SoundCloud, using the scsearch:
prefix. The string after the prefix is the search query.
const result = await node.rest.resolve('scsearch:snowhalation');if (!result?.tracks.length) return; // no tracksconst metadata = result.tracks.shift(); // get the first trackl
Tell the Lavalink node to join a Discord voice channel.
const player = await node.joinChannel({ guildId: 'your_guild_id', channelId: 'your_channel_id', shardId: 0 // if unsharded it will always be zero (depending on your library implementation)});// player is created and ready, do your thing
Play Track and change Playback Option
Here we are changing the volume, you can do other stuff as well.
player .playTrack({ track: metadata.track }) .setVolume(0.5);