Skip to content

Commit

Permalink
add readme file
Browse files Browse the repository at this point in the history
cleanup
  • Loading branch information
keshon committed Nov 13, 2024
1 parent 95d5015 commit df2df57
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 8 deletions.
102 changes: 102 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
![# Header](https://raw.githubusercontent.com/keshon/melodix/master/assets/readme-banner.webp)

# 🎵 Melodix — Self-hosted Discord music bot

Melodix is my pet project written in Go language that plays audio from YouTube and audio streaming links to Discord voice channels.

## 🌟 Features Overview

### 🎧 Playback Support
- 🎶 Single track added by song name or YouTube link.
- 🎶 Multiple tracks added via multiple YouTube links (space separated).
- 🎶 Tracks from public user YouTube playlists.
- 🎶 Tracks from YouTube "MIX" playlists.
- 📻 Internet radio streaming links (24/7 playback).

### ⚙️ Additional Features
- 🌐 Operation across multiple Discord servers.
- 📜 Access to recent tracks statistic and history of `play` commands.
- 🔄 Playback auto-resume support for connection interruptions.

### ⚠️ Current Limitations
- 🚫 The bot cannot play YouTube live streams or regional-locked videos.
- ⏸️ Playback auto-resume support may create noticeable pauses sometimes.
- ⏩ Playback speed may sometimes slightly vary.
- 🐞 It's not bug-free.

## 🚀 Try Melodix

You can test out Melodix in two ways:
- 🖥️ Download [compiled binaries](https://github.com/keshon/melodix-player/releases) (available only for Windows). Ensure FFMPEG is installed on your system and added to the global PATH variable. Follow the "Create bot in Discord Developer Portal" section to set up the bot in Discord.

- 🎙️ Join the [Official Discord server](https://discord.gg/NVtdTka8ZT) and use the voice and `#bot-spam` channels.

## 📝 Available Discord Commands

Melodix supports various commands with respective aliases (if applicable). Some commands require additional parameters.

### ▶️ Playback Commands
- `!play [title|url]` — Parameters: song name, YouTube URL, audio streaming URL.
- `!skip` — Skip to the next track in the queue.
- `!stop` — Stop playback, clear the queue, and leave the voice channel.

### 📋 Advanced Playback Commands
- `!list`— Show the current songs queue.
- `!pause`, `!resume` — Pause/resume current playback.

### 📊 Information Commands
- `!now` — Show the currently playing song.
- `!stats` — Show tracks played statistics with total playback duration and count.
- `!log` — Show the recent `play` commands by users.

### ⚙️ Utility Commands
- `!set-prefx [new_prefix]` — Set a custom prefix for a guild to avoid collisions with other bots.
- `melodix-reset-prefix` — Revert to the default prefix `!`.

### ℹ️ General Commands
- `!about ` — Show bot information.
- `!help` (aliases: `!h`, `!?`) — Show help cheatsheet.


### 💡 Usage Examples
To use the `play` command, provide a YouTube video title, URL:
```
!play Never Gonna Give You Up
!play https://www.youtube.com/watch?v=dQw4w9WgXcQ
!play http://stream-uk1.radioparadise.com/aac-320
```
Play multiple tracks (second link will be added to the queue):
```
!play https://www.youtube.com/watch?v=dQw4w9WgXcQ https://www.youtube.com/watch?v=OorZcOzNcgE
```

## 🔧 How to Set Up the Bot

### 🔗 Create a Bot in the Discord Developer Portal
To add Melodix to a Discord server, follow these steps:

1. Create an application in the [Discord Developer Portal](https://discord.com/developers/applications) and obtain the `APPLICATION_ID` (in the General section).
2. In the Bot section, enable `PRESENCE INTENT`, `SERVER MEMBERS INTENT`, and `MESSAGE CONTENT INTENT`.
3. Use the following link to authorize the bot: `discord.com/oauth2/authorize?client_id=YOUR_APPLICATION_ID&scope=bot&permissions=36727824`
- Replace `YOUR_APPLICATION_ID` with your Bot's Application ID from step 1.
4. Select a server and click "Authorize".
5. Grant the necessary permissions for Melodix to function correctly (access to text and voice channels).

After adding the bot, build it from sources or download [compiled binaries](https://github.com/keshon/melodix-player/releases). Docker deployment instructions are available in `docker/README.md`.

### 🛠️ Building Melodix from Sources
This project is written in Go, so ensure your environment is ready. Use the provided scripts to build Melodix from sources:
- `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.
- `build-dist-assemble`: Build the release version and assemble it as a distribution package (Windows only).

Rename `.env.example` to `.env` and store your Discord Bot Token in the `DISCORD_TOKEN` variable. Install [FFMPEG](https://ffmpeg.org/) (only recent versions are supported).

### 🐳 Docker Deployment
For Docker deployment, refer to `docker/README.md` for specific instructions.

## 🆘 Support
For any questions, get support in the [Official Discord server](https://discord.gg/NVtdTka8ZT).

## 📜 License
Melodix is licensed under the [MIT License](https://opensource.org/licenses/MIT).
Binary file added assets/readme-banner.webp
Binary file not shown.
2 changes: 1 addition & 1 deletion cmd/melodix/melodix.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ func (b *Bot) onMessageCreate(s *discordgo.Session, m *discordgo.MessageCreate)
for index, song := range songs {
emb.Fields = append(emb.Fields, &discordgo.MessageEmbedField{
Name: fmt.Sprintf("%d. %s", index+1, song.Title),
Value: fmt.Sprintf("[%s](%s)", song.Title, song.PublicLink),
Value: fmt.Sprintf("[%s](%s)", song.Source, song.PublicLink),
Inline: false,
})
}
Expand Down
2 changes: 2 additions & 0 deletions player/player.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ PLAYBACK_LOOP:
done := make(chan error)
// defer close(done)

time.Sleep(250 * time.Millisecond) // questionable

streaming := dca.NewStream(encoding, vc, done)
p.StatusSignals <- StatusPlaying

Expand Down
14 changes: 7 additions & 7 deletions song/song.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ var (
)

type Song struct {
Title string // Title of the song
PublicLink string // Link to the song page
Title string // title of the song
PublicLink string // link to the song page
StreamURL string // URL for streaming the song
StreamFilepath string // Path for streaming the song
Thumbnail Thumbnail // Thumbnail image for the song
Duration time.Duration // Duration of the song
SongID string // Unique ID for the song
Source SongSource // Source type of the song
StreamFilepath string // path for streaming the song
Thumbnail Thumbnail // thumbnail image for the song
Duration time.Duration // duration of the song
SongID string // unique ID for the song
Source SongSource // source type of the song
}

type Thumbnail struct {
Expand Down

0 comments on commit df2df57

Please sign in to comment.