An interactions-over-HTTP discord bot using discord.py.
discord.py is mainly focused around discord's real-time gateway and
doesn't support receiving interactions via HTTP. However, using the discord.py
client's login()
method, the bot can authenticate itself without
establishing a gateway connection, allowing discord.py to send API requests.
discord.py also has internal methods that allow manually dispatching interaction
events within the library from JSON payloads. As such, the bot could
simultaneously host a webserver using other libraries, in this case uvicorn
and FastAPI, and then relay those interactions to discord.py.
This bot requires Python 3.11+ to run. In addition, dependencies must be configured using Poetry.
-
Download the repository and navigate to the project root.
-
Install the dependencies via Poetry (if you have not set up a virtual environment, Poetry will create one for you):
poetry install
-
Copy the
example.env
file as.env
and fill in the required credentials. -
Start the bot and webserver:
poetry run uvicorn thehttpbot:app --host 0.0.0.0 --port 5000 --env-file .env
- Use the invite link provided in the terminal to invite your bot.
This project uses the MIT license.