Skip to content

Discord music bot with optional CS:GO integration, providing round-state-triggered music control, song lyrics and YouTube/Spotify integration

License

Notifications You must be signed in to change notification settings

byCrookie/discord-music

Repository files navigation

discord-music

Another music bot for discord. This bot is written in C# and uses Discord.Net, FFmpeg, yt-dlp, SpotifyApi-NET and lyrist.

Setup

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 with DISCORD_MUSIC_.

Discord

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.

Spotify

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.

Register

Use the register command to add the bot to a server.

dm register

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.

{
  "ffmpeg": "C:\\ffmpeg\\bin\\ffmpeg.exe"
}

yt-dlp

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"
}

Running

Run the bot using the run command.

dm run

Logging

Logging can be configured using options on all commands.

dm run --verbosity debug --log-file log.txt --quiet false

Other Commands

Store

To get your local storage size use the store command.

dm store

Clear

To clear your local storage use the store command with the clear option.

dm store --clear

Counter Strike

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.

Initialize

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

Run

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

Lyrics

Thanks asrvd - lyrist for the lyrics api. The bot uses the lyrics api to get the lyrics of the current song.

Development

Secrets

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

Token from https://discord.com/developers/applications/1200147726013300866/bot

dotnet user-secrets set "Discord:Token" ""

ApplicationId

ApplicationId from https://discord.com/developers/applications/1200147726013300866/information

dotnet user-secrets set "Discord:ApplicationId" ""

Publish

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.

Settings

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.jsonis 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.