No description
Find a file
2025-05-08 11:18:38 +02:00
.woodpecker chore: project boilerplate 2025-05-08 10:44:18 +02:00
.gitignore chore: project boilerplate 2025-05-08 10:44:18 +02:00
.goreleaser.yml chore: project boilerplate 2025-05-08 10:44:18 +02:00
Containerfile chore: project boilerplate 2025-05-08 10:44:18 +02:00
docker-compose.yml initial bot 2025-05-07 10:12:54 +02:00
go.mod chore: project boilerplate 2025-05-08 10:44:18 +02:00
go.sum initial bot 2025-05-07 10:12:54 +02:00
LICENSE chore: project boilerplate 2025-05-08 10:44:18 +02:00
main.go feat: show tne current playing station in the bot status 2025-05-08 11:18:38 +02:00
Makefile chore: project boilerplate 2025-05-08 10:44:18 +02:00
README.md feat: show tne current playing station in the bot status 2025-05-08 11:18:38 +02:00

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

  1. Install FFmpeg on your system:

    • Ubuntu/Debian: sudo apt install ffmpeg
    • macOS: brew install ffmpeg
    • Windows: Download from FFmpeg website
  2. 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
  3. 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
  4. 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

  1. Clone this repository
  2. Run the bot with your Discord token:
    DISCORD_TOKEN=your_token_here go run main.go
    
    Or
    go 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

  1. Build the Docker image:

    docker build -t discord-europa-fm .
    
  2. Run the container:

    docker run -e DISCORD_TOKEN=your_token_here discord-europa-fm
    

    With debug mode:

    docker run -e DISCORD_TOKEN=your_token_here -e DEBUG=1 discord-europa-fm
    

    With 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:

  1. Create a .env file with your Discord token:

    DISCORD_TOKEN=your_token_here
    DEBUG=1
    GUILD_ID=your_server_id  # Optional: for guild-specific command registration
    
  2. 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:

  1. Make sure FFmpeg is properly installed and available in your system PATH
  2. Verify that the bot has permissions to join and speak in voice channels
  3. Check that you're in a voice channel before using the play command
  4. 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:

  1. The bot is offline or not properly connected to Discord
  2. The slash commands haven't been properly registered with Discord
  3. The bot may need permissions it doesn't currently have

Solutions to try:

  1. Run the bot with -debug flag to get more detailed logs about what's happening
  2. Use guild-specific command registration with -guild your_server_id for faster updates (global commands can take up to an hour to propagate)
  3. Check if your bot has the "applications.commands" scope when you invited it to your server
  4. Try re-inviting the bot with the correct permissions and scopes
  5. Verify that your bot token is correct and not expired
  6. Check the Discord Developer Portal to make sure your application has the bot feature enabled

License

LICENSE