A high-level, functional programming wrapper to discord.py
Project description
Beymax API
A high-level, functional-focused wrapper to discord.py
About
This package started off as a personal discord bot, but as it grew in scope, I found the need to add my own utilities on top of the wonderful discord.py by GitHub user Rapptz. Beymax aims to reduce the amount of boilerplate needed to create a functioning Discord bot, while also exposing an API which is familiar to those used to writing event-driven code.
Differences from discord.py
- Essentially everything runs as an event listener. This includes tasks, commands, and context menus
- Events now have 3 phases: For an event called
event
, subscribers tobefore:event
are run first, thenevent
, and finallyafter:event
. - Events can be cancelled: Any listener to an event can call
event.cancel()
which will prevent any listeners in subsequent phases from being invoked. It does abort any listeners which have already ben called, such as other listeners to the current phase
- Events now have 3 phases: For an event called
- Client differences:
- Events can be scheduled in the future with
Client.dispatch_future()
. This adds an entry to the database, so the scheduled event will persist through restarts..dispatch_future()
guarantees precision within at least 30s of the scheduled time. - Key-value storage: Reduces boilerplate for storing/retreiving arbitrary small data points.
Client.set_value()
andClient.get_value()
can be used to store & retreive small strings from the database - Database migrations:
Client.migration()
allows schema migrations to be added in code. Migrations are called only the first time the bot starts up after a new migration is added. - Special message handlers: A small convenience layer over
Client.wait_for()
,Client.add_special()
allows a coroutine to be invoked any time a message is received which meets user-defined criteria - Native database integration: Beymax natively supports SQLAlchemy for interacting with databases in your bot.
- Events can be scheduled in the future with
- Cogs -> Suites: discord.py's concept of a
cog
is essentially the same as a Beymaxsuite
. Suites group together a set of commands, context menus, event listeners, database tables, etc which logically relate to each other. Suites can define their own interdependencies, ensuring that if a suite is loaded by your bot, all of its dependencies are also loaded. - UI Differences: discord.py's ui library follows an imperative style, where UI elements are defined in advance via subclassing. Beymax overrides this interface to provide a functionally-oriented style where UI elements are defined dynamically at runtime using function decorators.
- Argument parsing and command definition: Beymax mostly follows discord.py's style of defining command/context arguments via function annotations. Beymax extends this by allowing all argument metadata to be set in the annotations, including parameter descriptions.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
beymax-1.1.0.tar.gz
(37.9 kB
view details)
Built Distribution
beymax-1.1.0-py3-none-any.whl
(40.6 kB
view details)
File details
Details for the file beymax-1.1.0.tar.gz
.
File metadata
- Download URL: beymax-1.1.0.tar.gz
- Upload date:
- Size: 37.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2a4bc18e6821a96b52237ac60cf8883645dfa26cc4c3e748f18d5a6d9feec149 |
|
MD5 | 52c543ca631b1c39ca5b689bb7f08556 |
|
BLAKE2b-256 | ba216cfcf4d437e01ce2c9926db8b625f32dafb70f1b4088f77a0f6fdd4158a3 |
File details
Details for the file beymax-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: beymax-1.1.0-py3-none-any.whl
- Upload date:
- Size: 40.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b176e1b8520d9316cc2c4d32d803a1bdfd642f87bf48cfec366eeead342f05e5 |
|
MD5 | 3a2b2e2ca9d963fff710d196b289cb57 |
|
BLAKE2b-256 | 465bbae49b22a82fd3ee1425e5cd9a5998ff6e30da1796807ceb1e669e034aab |