This repository contains a Discord bot that uses discord.py, and a small aiohttp webserver that exposes a health and status endpoint.
-
On Render, create a new Web Service and connect this GitHub repo.
-
Select Runtime:
Python. -
Build Command: you can leave empty or use
pip install -r requirements.txt. -
Start Command:
python bot.py(theProcfilealready contains this). -
Set environment variables in the Render UI:
DISCORD_TOKEN: your bot tokenGROK_API_KEY: your Grok API key (if used)
-
Set the Health Check Path to
/health.- If your initial Render deploy tries to use Elixir/OTP (e.g.,
mix phx.digestor "Using Erlang version"), it means the service is configured with the wrong environment. - To fix this, either:
- In Render Dashboard, edit the service and change Environment to Python and update the Build & Start Commands accordingly, or
- Re-create a new Web Service and choose Python as the runtime and use the
startCommandpython bot.py(orProcfile) andbuildCommandpip install -r requirements.txt. - Ensure the Root Directory is set to your repo root (or
/) so Render detects the repository'sruntime.txt,requirements.txt,Procfile, andrender.yaml.
- If your initial Render deploy tries to use Elixir/OTP (e.g.,
Note: If you'd prefer to run the bot as a background worker, create a Background Worker in Render instead and use the same start command.
- Create a virtual environment and activate it:
python3 -m venv .venv
source .venv/bin/activate- Install dependencies:
pip install -r requirements.txt- Copy
.env.exampleto.envand add your tokens.
cp .env.example .env
# edit .env to add keys- Run the app locally:
python bot.py- Open http://localhost:8080/health to confirm the service is up (you should see
OK).