initial bot

This commit is contained in:
Felipe M 2025-05-07 10:12:54 +02:00
commit 2c7a5dff6c
Signed by: fmartingr
GPG key ID: CCFBC5637D4000A8
7 changed files with 747 additions and 0 deletions

139
README.md Normal file
View file

@ -0,0 +1,139 @@
# Discord EuropaFM Radio Bot
A Discord bot that streams EuropaFM Spanish radio to your voice channel.
## Requirements
- Go 1.22 or higher
- FFmpeg installed on your system
- Discord Bot Token
## Setup
1. Install FFmpeg on your system:
- Ubuntu/Debian: `sudo apt install ffmpeg`
- macOS: `brew install ffmpeg`
- Windows: Download from [FFmpeg website](https://ffmpeg.org/download.html)
2. Create a Discord Bot:
- Go to [Discord Developer Portal](https://discord.com/developers/applications)
- 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:
- `/europafm play` - Start streaming EuropaFM radio in your voice channel
- `/europafm stop` - Stop streaming and leave the voice channel
## 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