A simple Discord music bot that plays songs from YouTube and Spotify playlists in your voice channels.
- Play songs from YouTube by title or URL
- Play entire Spotify playlists with a single command
- Queue system for multiple songs
- Basic playback controls (pause, resume, skip)
- Clean and simple slash command interface
Before setting up RexTunes, make sure you have the following installed:
- Python 3.8 or higher
- FFmpeg installed and in your system PATH
- A Discord account and a Discord application with a bot
- A Spotify Developer account for playlist integration
-
Clone this repository or download the source code:
git clone https://github.com/yourusername/rextunes.git cd rextunes -
Create a virtual environment (recommended):
python -m venv .venv -
Activate the virtual environment:
- Windows:
.venv\Scripts\activate - macOS/Linux:
source .venv/bin/activate
- Windows:
-
Install the required dependencies:
pip install -r requirements.txt -
Create a
.envfile in the project root directory with the following variables:token=YOUR_DISCORD_BOT_TOKEN server_id=YOUR_DISCORD_SERVER_ID spot_id=YOUR_SPOTIFY_CLIENT_ID spot_secret=YOUR_SPOTIFY_CLIENT_SECRET
- Go to the Spotify Developer Dashboard
- Create a new application
- Note your Client ID and Client Secret
- Add these credentials to your
.envfile asspot_idandspot_secret
RexTunes requires FFmpeg to process audio streams. Installation instructions vary by platform:
- Download FFmpeg from ffmpeg.org or use a package manager like Chocolatey:
choco install ffmpeg - Add FFmpeg to your system PATH
- Install using Homebrew:
brew install ffmpeg
- Ubuntu/Debian:
sudo apt install ffmpeg - Fedora:
sudo dnf install ffmpeg - Arch Linux:
sudo pacman -S ffmpeg
- Go to the Discord Developer Portal
- Create a new application and add a bot
- Enable the following Privileged Gateway Intents:
- Message Content Intent
- Server Members Intent
- Copy your bot token and add it to your
.envfile - Use the following OAuth2 URL to invite your bot to your server:
Replace
https://discord.com/api/oauth2/authorize?client_id=YOUR_CLIENT_ID&permissions=3145728&scope=bot%20applications.commandsYOUR_CLIENT_IDwith your bot's client ID
-
Start the bot:
python main.py -
Use the following slash commands in your Discord server:
/play [song_title]- Play a song or add it to the queue/play [spotify_playlist_url]- Play an entire Spotify playlist/pause- Pause the current song/resume- Resume playback/skip- Skip to the next song in the queue/queue- Show the current song queue/stop- Stop playback and disconnect the bot
By default, the bot is configured to work with a single Discord server specified in your .env file. To enable multi-server support:
- Open
tunes.py - Comment out or remove this line:
await tree.sync(guild=discord.Object(id=GUILD_ID))
- Uncomment this line:
# await tree.sync() - Remove the
guild=discord.Object(id=GUILD_ID)parameter from all slash command definitions
- Bot doesn't respond to commands: Make sure the bot has the correct permissions and that slash commands are synced
- Audio doesn't play: Check that FFmpeg is correctly installed and in your PATH
- Error finding songs: Check your internet connection and YouTube search terms
- Spotify playlists not working: Verify your Spotify API credentials in the
.envfile
- Uses yt-dlp for YouTube integration
- Built with discord.py
- Uses spotipy for Spotify integration