Check out the docs to view the commands you can use while playing tracks.
Play over 265 million tracks for free on SoundCloud. Of course, there are other commands Lavalink has to offer. Stream Adele Easy On Me Preview (BOT - EXTREME) - Alvian ClinicMix DJ by AlvianClinicMix on desktop and mobile. The finished command should look like so: We can do so by checking : if ( = null)Īwait ctx.RespondAsync("There are no tracks loaded.") Īnd finally, we can call pause: await conn.PauseAsync() Var conn = node.GetGuildConnection() Īwait ctx.RespondAsync("Lavalink is not connected.") įor this command we will also want to check the player state to determine if we should send a pause command. If ( = null || = null)Īwait ctx.RespondAsync("You are not in a voice channel.") Public async Task Pause(CommandContext ctx) For this we can use most of the base from the play command: Var node = () Īwait ctx.RespondAsync("Not a valid voice channel.") Īwait ctx.RespondAsync($"Joined !") īeing able to pause the player is also useful. Using Īwait ctx.RespondAsync("The Lavalink connection is not established") So far, your command class should look something like this: using
First() method on the extensions connected nodes to get what we need. Play 176 - How to add Chat Bot to your web site by Course Income Secrets Podcast w/Jean-Serge Gagnon on desktop and mobile. Since we only have one connection we can use linq's. It can also filter nodes based on an optional voice region to use the closest nodes available. GetIdealNodeConnection() will return the least affected node through load balancing, which is useful for larger bots. Check if the connection exists, and tell the user if not.Get the node connection, using the same process.Check if the channel is a voice channel, and tell the user if not.You can either use linq or GetIdealNodeConnection() In order to connect to a voice channel, we'll need to do a few things. Public async Task Leave(CommandContext ctx, DiscordChannel channel) Public async Task Join(CommandContext ctx, DiscordChannel channel) Let's create the base for these commands: Your bot, and Lavalink, will need to connect to a voice channel to play music. Public class MyLavalinkCommands : BaseCommandModuleĪnd be sure to register it in your program file: CommandsNext = Discord.UseCommandsNext(new CommandsNextConfiguration For this we can make a simple configuration and command class: using DSharpPlus.CommandsNext Prerequisitesīefore we start we will need to make sure CommandsNext is configured. If you do not, you should learn here before continuing with this guide.
This article assumes that you know how to use CommandsNext.