Another music bot for discord. This bot is written in C# and uses Discord.Net, FFmpeg, yt-dlp, SpotifyApi-NET and lyrist.
Warning: The token should be kept secret and not shared with anyone. If the token is shared, it should be regenerated.
Note: If you dont want to use the
appsettings.json
file, you can use environment variables prefixed withDISCORD_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
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.
{
"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"
}
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.
dotnet publish .\DiscordMusic.Cli\ --output "D:\Apps\Discord\Music\DiscordMusic"
appsettings.json
will be included in the publish directory but not overwritten.
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.