Boilerplate code to build discord bots
- FastAPI - for the webserver, and the API
- Disnake - for the discord bot
- Prisma - for the database
- Clone the repo
- Create a virtual environment
- Install the requirements
- Create .env files
- Run the migrations
- Run the bot
git clone --depth 1 https://github.com/yatochka-dev/discord-bot-boilerplate <YOUR_PROJECT_NAME>
cd <YOUR_PROJECT_NAME>
python -m venv <YOUR_VENV_NAME>
# Windows
<YOUR_VENV_NAME>\Scripts\activate
# Linux
source <YOUR_VENV_NAME>/bin/activate
pip install -r requirements.txt
python edit_dotenv.py --help
python edit_dotenv.py init # Will create .env files with default values
python edit_dotenv.py new --name <VARIABLE_NAME> # Will create a new variable in both .env files
prisma generate
prisma migrate dev --name init
!!!Don't forget to activate your venv before generating prisma!!!
python -m uvicorn main:app --reload
In <YOUR_PROJECT_NAME>.app.bot.py file you can find class named AppSettings. This class contains all the settings for your bot. Switching between testing and production mode is done by changing the TESTING variable.
- Add mixins.pyi file to venv/Lib/site-packages/disnake with following content:
class Hashable:
@overload
@property
def snowflake(self) -> str: ...