📄️ Intro
Playing music is some of the most common use cases for Discord bots. Lavalink4NET is a library that makes it easy to add music playback to your bot from various sources including YouTube, SoundCloud, and Spotify.
📄️ Setting up Lavalink
If you are new to bot developing and/or Lavalink, you might be wondering what Lavalink is and why you need it. Lavalink is a standalone audio player that is used by many Discord music bots. It is written in Java and can be hosted on your own server or even computer. Lavalink4NET is a library that allows you to easily connect to Lavalink and use it in your bot.
📄️ Installation
Lavalink4NET comes with a lot of features and is divided into multiple packages. You can choose which packages you want to use. We will start with the basic package you need.
📄️ Getting Started
In the previous chapters, we have set up Lavalink4NET and Lavalink. Now we will create a simple bot that can play music using Discord.Net. We will start with a simple bot that can play music. After that, we will add some more features to our bot.
📄️ Retrieving the player
Let us take a look at this method to retrieve the player. We call this method from the commands module, whenever we need a player instance. The method will check if a player already exists for the guild and return it. If no player exists, it will create a new player and return it for us.
📄️ Configuring Lavalink4NET
Lavalink4NET can be configured by utilizing dependency injection. This allows you to configure Lavalink4NET in a central place and use it in your bot.