A Discord bot for managing music playback through Spotify and Alexa devices. Users can add songs to a Spotify playlist and control playback through Discord commands.
- Add songs to a designated Spotify playlist (
!addsong) - Play songs on Alexa devices (
!play) - Integration with Spotify and Alexa APIs
- Python 3.12+
- Docker (optional)
- Discord Bot Token
- Spotify API credentials
- Alexa API credentials
Create a .env file in the root directory with the following variables:
DISCORD_TOKEN=your_discord_token
CHANNEL_ID=your_channel_id
ECHO_DEVICE_NAME=your_alexa_device_name
SPOTIFY_CLIENT_ID=your_spotify_client_id
SPOTIFY_CLIENT_SECRET=your_spotify_client_secret
SPOTIFY_PLAYLIST_ID=your_playlist_id- Install dependencies:
pip install -r requirements.txt- Run the bot:
python main.py- Build the container:
docker build -t battleford-jukebox .- Run the container:
docker run --env-file .env battleford-jukeboxbattleford-jukebox/
├── commands/ # Discord command modules
├── controllers/ # Core controller classes
├── config.py # Configuration and environment variables
├── main.py # Application entry point
├── requirements.txt # Python dependencies
└── Dockerfile # Container configuration
- Create a new file in the
commands/directory:
from discord.ext import commands
class NewCommand(commands.Cog):
def __init__(self, bot, *required_controllers):
self.bot = bot
# Store any required controllers
@commands.command(name='commandname')
async def command_method(self, ctx, *args):
# Command implementation- Register the command in
discord_controller.py:
from commands.new_command import NewCommand
class DiscordController:
def register_commands(self):
# ... existing commands ...
self.bot.add_cog(NewCommand(self.bot, *required_controllers))- Create a new controller class in
controllers/:
class NewController:
def __init__(self):
# Initialize controller
pass
def some_method(self):
# Implement controller functionality
pass- Initialize the controller in
main.py:
new_controller = NewController()
discord_controller = DiscordController(
spotify_controller,
alexa_controller,
new_controller
)!addsong <song name>- Adds a song to the Spotify playlist!play <song name>- Plays a song on the configured Alexa device
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request