Skip to content

A template for speeding up development of discord bots using disnake and postgresql

License

Notifications You must be signed in to change notification settings

Exenifix/disnake-bot-template-postgres

Repository files navigation

Disnake Bot Template (postgresql)

A template for speeding up development of discord bots using disnake and postgresql.

Tools and Config

Poetry

Template uses poetry for dependencies management. Use poetry install to initialise Poetry and begin development.

Pre-commit

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.

Formatting and Linting

Template uses RUFF for linting, black for formatting and isort for sorting imports.

Environment Vars

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.

CI

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

Functionality

Postgres Database Class

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.

Error Logging

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.

General Logging

Template uses exencolorlogs.FileLogger for logging. Logs are saved to autogenerated folder data/logs by default, may be overwritten in utils.paths.

Views

Template offers generic views in utils.views that are easy to use.

About

A template for speeding up development of discord bots using disnake and postgresql

Topics

Resources

License

Stars

Watchers

Forks