A template for speeding up development of discord bots using disnake and postgresql.
Template uses poetry for dependencies management. Use poetry install
to initialise Poetry and begin development.
Template has config files for pre-commit
, the tool itself is a dev dependency. Use pre-commit install
and pre-commit run --all-files
to set it up.
Template uses RUFF
for linting, black
for formatting and isort
for sorting imports.
Required vars are controlled using exenenv.EnvironmentProfile
in utils.env
. All variables without default values must be set. In utils.env.DatabaseEnvironment
if DSN
is present, presence of other variables is not required. You can use .env
file for defining the environment variables.
Template has Dockerfile
and docker-compose.yaml
files for running bot in Docker container, as well as GitHub workflow for automatic update. You need to edit docker-compose.yaml
with your data dir, container name and database name
utils.database.Database
encapsulates some methods of asyncpg.Pool
and manages its creation automatically. You can access the class in cogs via self.bot.db
.
Template has basic builtin error handler (ext.system.SystemListeners.on_slash_command_error
) and error notifier (utils.bot.Bot.on_error
). The utils.constants.LOG_CHANNEL_ID
must be set in order for notifier to work.
Template uses exencolorlogs.FileLogger
for logging. Logs are saved to autogenerated folder data/logs
by default, may be overwritten in utils.paths
.
Template offers generic views in utils.views
that are easy to use.