A .NET-based HTTP endpoint that allows other programs to send messages through a Discord bot to users.
- Send plain text messages to Discord users
- Send rich embed messages with customizable fields
- Simple HTTP POST interface
- Docker support for easy deployment
- Docker (optional, for containerized deployment)
- Discord bot token
- .NET 8.0 SDK (for local development)
- Build the image:
docker build -t discord-bot-endpoint .
- Run the container:
docker run -d \
--name discord-bot \
-p PORT:80 \
-e DISCORD_TOKEN=your-token-here \
isolyth/discord-bot-endpoint:latest
- Create a docker-compose.yml:
version: '3.8'
services:
discord-bot:
image: isolyth/discord-bot-endpoint:latest
container_name: discord-bot
environment:
- DISCORD_TOKEN=your-token-here
ports:
- "PORT:80" //Change PORT to whatever port you would this to be accessible at
restart: unless-stopped
- Run with docker-compose:
docker-compose up -d
- Restore dependencies:
dotnet restore
- Run the application:
dotnet run
- URL:
http://localhost:PORT
- Method: POST
- Content-Type: application/json
{
"target": "user", // Required: Currently only "user" is supported
"userId": 123456789, // Required: Discord user ID (numeric)
"message": "Hello world", // Optional: Plain text message
"embed": { // Optional: Rich embed object
"title": "Title here",
"description": "Main content here",
"color": 4144959, // Decimal color value
"timestamp": "2024-01-24T11:21:00Z", // ISO 8601 timestamp
"fields": [
{
"name": "Field Title",
"value": "Field content",
"inline": false
}
]
}
}
- Either
message
orembed
must be provided userId
must be a numeric value (not a string)- All embed fields are optional
curl -X POST http://localhost:PORT \
-H "Content-Type: application/json" \
-d '{
"target": "user",
"userId": 123456789,
"message": "Hello from the Discord bot!"
}'
curl -X POST http://localhost:PORT \
-H "Content-Type: application/json" \
-d '{
"target": "user",
"userId": 123456789,
"embed": {
"title": "Important Notification",
"description": "This is the main content of the embed",
"fields": [
{
"name": "Status",
"value": "Active",
"inline": false
}
],
"color": 4144959,
"timestamp": "2024-01-24T11:21:00Z"
}
}'
- 200: Message sent successfully
- 400: Invalid request format or parameters
- 404: User not found
- 405: Method not allowed (only POST is supported)
- 500: Server error
- 503: Discord client is not ready
{
"message": "Status message here"
}
DISCORD_TOKEN
: Your Discord bot token (required)
The repository includes CI/CD workflows that:
- Build and test the application
- Create and publish Docker images
- Run on pushes to main and pull requests
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to your fork
- Create a Pull Request
- I don't have much experience with docker, if you know of a way to make the image smaller, that would be great! The 80mb download isn't ideal
- Test it! Make sure it works on your machines too!
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.
This program has sections written by LLM. The code has been tested and verified to work (On my machine anyway). As always, excercise caution where LLMs are involved and don't rely on this program as your final line of knowing-about-things-happening.