This repository has been archived by the owner on Nov 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5b60028
Showing
52 changed files
with
4,620 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# | ||
# MELODIX SETTINGS | ||
# | ||
|
||
# Set prefix to bot's commands - useful for development with same bots in the channel. | ||
DISCORD_COMMAND_PREFIX="!" | ||
|
||
# Discord bot token acquired from Discord Developer Portal | ||
DISCORD_BOT_TOKEN=<INSERT TOKEN HERE> | ||
|
||
# Enable REST API server | ||
REST_ENABLED=true | ||
|
||
# Set REST API server to release mode (empty value will switch to debug mode) | ||
REST_GIN_RELEASE=true | ||
|
||
# Audio frame duration (can be 20, 40, or 60 ms) | ||
# Everything above 20 will ruin sound quality | ||
DCA_FRAME_DURATION=20 | ||
|
||
# Audio encoding bitrate in kb/s (can be 8 - 128) | ||
DCA_BITRATE=64 | ||
|
||
# Expected packet loss percentage | ||
DCA_PACKET_LOSS=3 | ||
|
||
# Raw opus output (no metadata or magic bytes) | ||
DCA_RAW_OUTPUT=true | ||
|
||
# Audio application: audio or lowdelay | ||
DCA_APPLICATION=lowdelay | ||
|
||
# Compression level (higher is better quality but slower encoding, 0 - 10) | ||
DCA_COMPRESSION_LEVEL=10 | ||
|
||
# How big the frame buffer should be (50 frames = 1 second at 20ms of frame duration) | ||
DCA_BUFFERED_FRAMES=200 | ||
|
||
# Whether VBR is used or not (variable bitrate) | ||
DCA_VBR=true | ||
|
||
# If set then eof is treated like an error and causes reconnection, this is useful for live / endless streams. | ||
DCA_RECONNECT_AT_EOF=true | ||
|
||
# If set then even streamed/non seekable streams will be reconnected on errors. | ||
DCA_RECONNECT_STREAMED=true | ||
|
||
# Reconnect automatically in case of TCP/TLS errors during connect. | ||
DCA_RECONNECT_ON_NETWORK_ERROR=true | ||
|
||
# A comma-separated list of HTTP status codes to reconnect on. | ||
# The list can include specific status codes (e.g., ’503’) or the strings ’4xx’ / ’5xx’ | ||
DCA_RECONNECT_ON_HTTTP_ERROR=4xx,5xx | ||
|
||
# Sets the maximum delay in seconds after which to give up reconnecting | ||
DCA_RECONNECT_MAX=1 | ||
|
||
# Set ffmpeg binary absolute path, comment out if globally installed | ||
DCA_FFMPEG_BINARY_PATH=c:\Users\SokolovIA\ProgramsDev\ffmpeg\bin\ | ||
|
||
# Enable ffmpeg stats logging per each second of encoding | ||
DCA_ENCODING_LINE_LOG=true | ||
|
||
# Override the User-Agent header. If not specified, an empty string will be sent | ||
DCA_USER_AGENT=Mozilla/5.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/.VSCodeCounter | ||
main.exe | ||
melodix.exe | ||
*.db | ||
/.env | ||
*.upx | ||
logs/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 Innokentiy Sokolov | ||
|
||
Project: Melodix Discord Player | ||
Author: Innokentiy Sokolov | ||
Contact: [email protected] | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
![# Header](https://raw.githubusercontent.com/keshon/assets/main/melodix-discord-player/header.png) | ||
|
||
# Melodix Discord Player | ||
|
||
Melodix is a versatile Discord music bot tailored to manage and play music seamlessly in your server. With a primary focus on offering a smooth music playback experience, Melodix supports multiple Discord servers. | ||
|
||
## Project Overview | ||
|
||
Melodix aims to be an easy-to-use and versatile Discord music bot. Its key objectives include: | ||
|
||
- Seamlessly playing lengthy tracks. | ||
- Handling interruptions from sources like YouTube or Discord's gateway. | ||
- Maintaining a user-friendly interface. | ||
|
||
![# Playing Example](https://raw.githubusercontent.com/keshon/assets/main/melodix-discord-player/playing.jpg) | ||
|
||
## Features | ||
|
||
Melodix includes the following features: | ||
|
||
- Play music from YouTube. | ||
- Pause and resume playback. | ||
- Skip to the next track. | ||
- Manage a queue for music playback. | ||
- Access the history of previously played tracks. | ||
- Operate across multiple Discord servers. | ||
- API access for integration. | ||
|
||
## Getting Started | ||
|
||
### Adding the Bot to a Discord Server | ||
|
||
To add Melodix to your Discord server: | ||
|
||
1. Create a bot at the [Discord Developer Portal](https://discord.com/developers/applications) and acquire the Bot's CLIENT_ID. | ||
2. Use the following link: `discord.com/oauth2/authorize?client_id=YOUR_CLIENT_ID_HERE&scope=bot&permissions=36727824` | ||
- Replace `YOUR_CLIENT_ID_HERE` with your Bot's Client ID from step 1. | ||
3. The Discord authorization page will open in your browser, allowing you to select a server. | ||
4. Choose the server where you want to add Melodix and click "Authorize". | ||
5. If prompted, complete the reCAPTCHA verification. | ||
6. Grant Melodix the necessary permissions for it to function correctly. | ||
7. Click "Authorize" to add Melodix to your server. | ||
|
||
Once added, Melodix will be available in your Discord server, ready for music playback and other functionalities. | ||
|
||
### Building Melodix | ||
|
||
Melodix is written in the Go language, allowing it to run on a *server* or as a *local* program. | ||
|
||
**Local Usage** | ||
There are several scripts provided for building Melodix: | ||
- `bash-and-run.bat` (or `.sh` for Linux): Build the debug version and execute. | ||
- `build-release.bat` (or `.sh` for Linux): Build the release version. Note: The UPX packer is called as a final step; if not installed, comment it out. | ||
|
||
For local usage, run these scripts for your operating system and rename `.env.example` to `.env`, storing your Discord Bot Token in the `DISCORD_BOT_TOKEN` variable. | ||
|
||
**Server Usage** | ||
To build and deploy the bot in a Docker environment refer to the `deploy/README.md` for specific instructions. | ||
|
||
Once the binary file is built, the `.env` file is filled, and the Bot is added to your server, Melodix is ready for operation. | ||
|
||
### Discord Commands and Aliases | ||
|
||
Melodix supports various commands with their respective aliases to control music playback. Some commands require additional parameters: | ||
|
||
- Commands & Aliases: | ||
- `pause` (`!`, `>`) | ||
- `resume` (`play`, `>`) | ||
- `play` (`p`, `>`) - Parameters: YouTube video URL, history ID, or track title | ||
- `skip` (`ff`, `>>`) | ||
- `list` (`queue`, `l`) | ||
- `add` (`a`, `+`) - Parameters: YouTube video URL or history ID, or track title | ||
- `exit` (`stop`, `e`, `x`) | ||
- `help` (`h`, `?`) | ||
- `history` (`time`, `t`) - Parameters: `duration` or `count` | ||
- `about` (`v`) | ||
- `register` | ||
- `unregister` | ||
|
||
Commands should be prefixed with `!` by default. For instance, `!play`, `!>>`, and so on. | ||
|
||
To use the `play` and `add` commands, provide a YouTube video title, URL, or a history ID as a parameter, e.g.: | ||
`!play Never Gonna Give You Up` | ||
or | ||
`!p https://www.youtube.com/watch?v=dQw4w9WgXcQ` | ||
or | ||
`!> 5` (assuming `5` is an id that can be seen from history: `!history`) | ||
|
||
Similarly, for adding a song to the queue, use a similar approach. | ||
|
||
### API Access and Routes | ||
|
||
Melodix provides various routes for different functionalities: | ||
|
||
#### Guild Routes | ||
|
||
- `GET /guild/ids`: Retrieve active guild IDs. | ||
- `GET /guild/playing`: Obtain information about the currently playing track in each active guild. | ||
|
||
#### Player Routes | ||
|
||
- `GET /player/play/:guild_id?url=<youtube_video_url>`: Play a track in a specific guild. | ||
- `GET /player/pause/:guild_id`: Pause playback in a specific guild. | ||
- `GET /player/resume/:guild_id`: Resume playback in a specific guild. | ||
|
||
#### History Routes | ||
|
||
- `GET /history`: Access the overall history of played tracks. | ||
- `GET /history/:guild_id`: Fetch the history of played tracks for a specific guild. | ||
|
||
## Join the Official Melodix Discord Server | ||
|
||
Join [official Discord server](https://discord.gg/2rArYVPYfR) to get support, and share your experiences! | ||
|
||
## Acknowledgment | ||
|
||
Melodix project drew inspiration from [Muzikas](https://github.com/FabijanZulj/Muzikas), a user-friendly Discord bot created by Fabijan Zulj. | ||
The banner images used in this project were sourced from [Freepik](https://www.freepik.com), attributed to contributors [@GarryKillian](https://www.freepik.com/author/garrykillian) and [@rawpixel.com](https://www.freepik.com/author/rawpixel-com). | ||
|
||
## Contribution | ||
|
||
While contributions are welcome, please note that this is primarily a one-person project designed as a Discord music player, especially suited for lengthy DnD sessions. | ||
|
||
## License | ||
|
||
Melodix is licensed under the [MIT License](https://opensource.org/licenses/MIT). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
@echo off | ||
|
||
rem | ||
rem BUILD | ||
rem | ||
|
||
rem Get Go version | ||
for /f "tokens=3" %%i in ('go version') do set GO_VERSION=%%i | ||
|
||
rem Get the build date | ||
for /f "tokens=*" %%a in ('powershell -command "Get-Date -UFormat '%%Y-%%m-%%dT%%H:%%M:%%SZ'"') do set BUILD_DATE=%%a | ||
|
||
go build -o melodix.exe -ldflags "-X app/internal/version.BuildDate=%BUILD_DATE% -X app/internal/version.GoVersion=%GO_VERSION%" cmd\main.go && melodix.exe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
# BUILD | ||
|
||
# Get Go version | ||
GO_VERSION=$(go version | awk '{print $3}') | ||
|
||
# Get the build date | ||
BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") | ||
|
||
go build -o melodix -ldflags "-X app/internal/version.BuildDate=$BUILD_DATE -X app/internal/version.GoVersion=$GO_VERSION" cmd/main.go && ./melodix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
@echo off | ||
|
||
rem | ||
rem BUILD | ||
rem | ||
|
||
rem Get Go version | ||
for /f "tokens=3" %%i in ('go version') do set GO_VERSION=%%i | ||
|
||
rem Get the build date | ||
for /f "tokens=*" %%a in ('powershell -command "Get-Date -UFormat '%%Y-%%m-%%dT%%H:%%M:%%SZ'"') do set BUILD_DATE=%%a | ||
|
||
go build -o melodix.exe -ldflags "-s -X app/internal/version.BuildDate=%BUILD_DATE% -X app/internal/version.GoVersion=%GO_VERSION%" cmd\main.go | ||
|
||
upx melodix.exe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
# BUILD | ||
|
||
# Get Go version | ||
GO_VERSION=$(go version | awk '{print $3}') | ||
|
||
# Get the build date | ||
BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") | ||
|
||
go build -o melodix -ldflags "-s -X app/internal/version.BuildDate=$BUILD_DATE -X app/internal/version.GoVersion=$GO_VERSION" cmd/main.go | ||
|
||
upx melodix |
Oops, something went wrong.