Another music bot for discord. This bot is written in C# and uses Discord.Net, FFmpeg, yt-dlp, SpotifyApi-NET and lyrist.
Warning: Only win-x64, linux-x64 and linux-arm64 are currently fully supported. The bot will not work on other architectures if opus and libsodium are not installed on the system.
Warning: The token should be kept secret and not shared with anyone. If the token is shared, it should be regenerated.
Note: If you do not want to use the
appsettings.json
file, you can use environment variables prefixed withDISCORD_MUSIC_
. This is required when using docker to deploy discord-music. Further information can be found in the Configuration section.
The bot uses the appsettings.json
file for configuration values. If a value is not found in the appsettings.json
file it will look for an environment variable prefixed with DISCORD_MUSIC_
.
Make sure to use double underscores __
for nested properties. Example: DISCORD_MUSIC_DISCORD__TOKEN
.
When providing a list, use an indexer __0
for the first item, __1
for the second item and so on.
Example: DISCORD_MUSIC_DISCORD__WHITELIST__0=music
.
Go to https://discord.com/developers/applications and create a new application.
Replace the Discord:ApplicationId
in the appsettings.json
file with the application id of your new application.
Next replace the Discord:Token
in the appsettings.json
file with the token of your new application.
Go to https://developer.spotify.com/dashboard/applications and create a new application.
Replace the Spotify:ClientId
in the appsettings.json
file with the client
id of your new application. Next replace the Spotify:ClientSecret
in the appsettings.json
file with the client secret of your new application.
Use the register command to add the bot to a server.
dm register
Dockerfile lets you build a docker image of the bot. The argument RUNTIME defines
the target runtime of the image. The default value is linux-x64
. All config values have to be provided as environment
variables.
This can be achieved by using the --env-file
option of the docker run
command or other methods to pass environment
variables to the container.
## FFmpeg
The bot requires FFmpeg to be installed on the system. Download it
from https://www.ffmpeg.org/download.html and add it to the system path
or place it in the same directory as the bot. If you want to specify the path
explicitly change the `ffmpeg` value in the `appsettings.json` file to the path of
the FFmpeg executable.
```json
{
"ffmpeg": "C:\\ffmpeg\\bin\\ffmpeg.exe"
}
The bot requires yt-dlp to be installed on the system. Download it
from https://github.com/yt-dlp/yt-dlp/releases and add it to the system path
or place it in the same directory as the bot. If you want to specify the path
explicitly change the ytdlp
value in the appsettings.json
file to the path of
the yt-dlp executable.
{
"ytdlp": "C:\\yt-dlp\\yt-dlp.exe"
}
The bot requires the Opus codec to be installed on the system. Some platforms/runtimes are directly supported by discord-music and do not require the Opus codec to be installed. If you receive an error message about the Opus codec not being found, download it from https://opus-codec.org/ if possible or build it from source.
The bot requires the Libsodium library to be installed on the system. Some platforms/runtimes are directly supported by discord-music and do not require the Libsodium library to be installed. If you receive an error message about the Libsodium library not being found, download it from https://libsodium.org/ if possible or build it from source.
Run the bot using the run command.
dm run
Logging can be configured using options on all commands.
dm run --verbosity debug --log-file log.txt --quiet false
To get your local storage size use the store command.
dm store
To clear your local storage use the store command with the clear option.
dm store --clear
dmcs
is a command line tool to integrate discord-music with Counter Strike.
Based on the current game round states the bot will play or pause the music.
To initialize the Counter Strike integration use the init
command. It
will create a gamestate_integration_dm.cfg
file in the csgo/cfg
directory.
dmcs init
To run the Counter Strike integration use the run
command. It will start
the bot and interact with discord-music based on the current game round states.
dmcs run
Thanks asrvd - lyrist for the lyrics api. The bot uses the lyrics api to get the lyrics of the current song.
During development environment variables can not be used. Instead use the dotnet user-secrets
command to set the
secrets
and use the appsettings.Development.json
for other settings.
Token from https://discord.com/developers/applications/1200147726013300866/bot
dotnet user-secrets set "Discord:Token" ""
ApplicationId from https://discord.com/developers/applications/1200147726013300866/information
dotnet user-secrets set "Discord:ApplicationId" ""
To publish the bot use the dotnet publish
command. appsettings.json
will be included in the publish directory but
not overwritten.
dotnet publish .\DiscordMusic.Cli\ --output "D:\Apps\Discord\Music\DiscordMusic"
To specify the runtime use the --runtime
option. Available runtimes can be
found here.
dotnet publish .\DiscordMusic.Cli\ --output "D:\Apps\Discord\Music\DiscordMusic" --runtime win-x64
To change settings use the appsettings.Development.json
file. This file
is generated once from the appsettings.Example.json
file during the first build.
The appsettings.Development.json
is not included in the
repository (.gitignore
). applicationId
and token
are
not included in the appsettings.Example.json
file and should not
be included in the appsettings.Development.json
file. Instead use
the dotnet user-secrets
command to set the secrets.