A simple Discord bot built with Serenity framework that acts as a proxy, forwarding user queries to another service and returning the responses.
- Slash command
/bot
that forwards user queries to a specified endpoint - Dockerized for easy deployment
- Ready for DigitalOcean App Platform
- Rust (latest stable)
- Discord Bot Token
- Endpoint URL for forwarding requests
Create a .env
file in the root directory with the following variables:
DISCORD_TOKEN=your_discord_bot_token
TARGET_URL=https://your-target-service.com/api/endpoint
- Go to the Discord Developer Portal
- Create a new application
- Navigate to the "Bot" tab and create a bot
- Enable the following Privileged Gateway Intents:
- Message Content Intent
- Copy the bot token and add it to your
.env
file - Use the OAuth2 URL Generator with the following scopes:
bot
applications.commands
- Invite the bot to your server
- Clone this repository
- Set up your
.env
file with the required variables - Run the bot:
cargo run
docker build -t discord-proxy-bot .
docker run -e DISCORD_TOKEN=your_token -e TARGET_URL=your_url discord-proxy-bot
- Fork or push this repository to GitHub
- In the DigitalOcean dashboard, create a new App
- Select your repository
- Configure the environment variables:
DISCORD_TOKEN
: Your Discord bot tokenTARGET_URL
: The URL to forward requests to
- Deploy the app
You can also use the included app.yaml
file to deploy directly with the DigitalOcean CLI:
doctl apps create --spec app.yaml
Once the bot is running and added to your server, you can use the slash command:
/bot your query here
The bot will forward "your query here" to the target service and respond with the result.
The target service should return a JSON response with the following structure:
{
"response": "This is the response text that will be sent back to Discord."
}
For a more robust deployment, you can add a simple health check endpoint:
- Add the
warp
package to your dependencies - Implement a simple HTTP server with a
/health
endpoint - Make sure your app listens on the port specified in the App Platform config (default: 8080)
MIT