Giter Club home page Giter Club logo

discord-music's Introduction

discord-music

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

Runtimes

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.

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 do not want to use the appsettings.json file, you can use environment variables prefixed with DISCORD_MUSIC_. This is required when using docker to deploy discord-music. Further information can be found in the Configuration section.

Configuration

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.

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 (Optional)

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

Docker

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

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

Opus

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.

Libsodium

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.

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. appsettings.json will be included in the publish directory but not overwritten.

dotnet publish .\DiscordMusic.Cli\ --output "D:\Apps\Discord\Music\DiscordMusic"

Runtime

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

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.