| .woodpecker | ||
| .gitignore | ||
| .goreleaser.yml | ||
| Containerfile | ||
| docker-compose.yml | ||
| go.mod | ||
| go.sum | ||
| LICENSE | ||
| main.go | ||
| Makefile | ||
| README.md | ||
Discord Radio Bot
A Discord bot that streams radio stations to your voice channel.
Requirements
- Go 1.22 or higher
 - FFmpeg installed on your system
 - Discord Bot Token
 
Features
- Streams radio stations to Discord voice channels
 - Slash command interface for easy control
 - Support for multiple radio stations
 - Container-ready with provided Containerfile
 
Setup
- 
Install FFmpeg on your system:
- Ubuntu/Debian: 
sudo apt install ffmpeg - macOS: 
brew install ffmpeg - Windows: Download from FFmpeg website
 
 - Ubuntu/Debian: 
 - 
Create a Discord Bot:
- Go to Discord Developer Portal
 - Create a new application
 - Go to the "Bot" tab and click "Add Bot"
 - Under "Privileged Gateway Intents", enable "Server Members Intent"
 - Copy your bot token
 
 - 
Invite the bot to your server:
- Go to OAuth2 > URL Generator
 - Select "bot" and "applications.commands" scopes
 - Select permissions: "Connect", "Speak", "Send Messages"
 - Open the generated URL and authorize the bot for your server
 
 - 
Get your Server ID (for guild-specific command registration):
- Enable Developer Mode in Discord (User Settings > Advanced > Developer Mode)
 - Right-click on your server name in the server list and select "Copy ID"
 - Alternatively, you can see the server ID in the bot's debug logs when it connects
 
 
Usage
Running from source
- Clone this repository
 - Run the bot with your Discord token:
OrDISCORD_TOKEN=your_token_here go run main.gogo run main.go -token your_token_here 
Command-line options
The bot accepts the following command-line options:
-token string: Discord bot token (can also be set via DISCORD_TOKEN environment variable)-debug: Enable debug logging for more verbose output (helpful for troubleshooting)-guild string: Register commands for a specific guild (server) instead of globally - this is faster for testing (commands update instantly)
Example with debug mode and guild-specific registration:
go run main.go -token your_token_here -debug -guild your_server_id
Using Docker
- 
Build the Docker image:
docker build -t discord-europa-fm . - 
Run the container:
docker run -e DISCORD_TOKEN=your_token_here discord-europa-fmWith debug mode:
docker run -e DISCORD_TOKEN=your_token_here -e DEBUG=1 discord-europa-fmWith guild-specific command registration:
docker run -e DISCORD_TOKEN=your_token_here -e GUILD_ID=your_server_id discord-europa-fm 
Alternatively, use docker-compose:
- 
Create a
.envfile with your Discord token:DISCORD_TOKEN=your_token_here DEBUG=1 GUILD_ID=your_server_id # Optional: for guild-specific command registration - 
Run with docker-compose:
docker-compose up -d 
Commands
Once the bot is running, you can use the following slash commands in your Discord server:
/radio play station:[station]- Start streaming the selected radio station in your voice channel/radio stop- Stop streaming and leave the voice channel
Available Radio Stations
The bot currently supports the following radio stations:
- Europa FM - La radio de éxitos musicales
 - COPE - A tope con la
 
To add more stations, modify the stations map in the source code.
Adding New Stations
To add a new radio station, you only need to update the stations map in the main.go file:
stations = map[string]Station{
    "europafm": {
        Name:        "Europa FM",
        StreamURL:   "https://atres-live.europafm.com/live/europafm/bitrate_1.m3u8",
        Description: "La radio de éxitos musicales",
    },
    "cope": {
        Name:        "COPE",
        StreamURL:   "http://flucast31-h-cloud.flumotion.com/cope/net1.mp3",
        Description: "A tope con la",
    },
    // Add your new station here
    "newstation": {
        Name:        "New Station Name",
        StreamURL:   "https://stream-url-for-the-station",
        Description: "Short description of the station",
    },
}
The choices for the radio command will be automatically generated based on this map.
Troubleshooting
If you're having audio issues:
- Make sure FFmpeg is properly installed and available in your system PATH
 - Verify that the bot has permissions to join and speak in voice channels
 - Check that you're in a voice channel before using the play command
 - Make sure the radio stream URL is still valid
 
Unknown Integration Error
If you see "Unknown Integration" when using slash commands, it might be because:
- The bot is offline or not properly connected to Discord
 - The slash commands haven't been properly registered with Discord
 - The bot may need permissions it doesn't currently have
 
Solutions to try:
- Run the bot with 
-debugflag to get more detailed logs about what's happening - Use guild-specific command registration with 
-guild your_server_idfor faster updates (global commands can take up to an hour to propagate) - Check if your bot has the "applications.commands" scope when you invited it to your server
 - Try re-inviting the bot with the correct permissions and scopes
 - Verify that your bot token is correct and not expired
 - Check the Discord Developer Portal to make sure your application has the bot feature enabled