Skip to main content

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 to before:event are run first, then event, and finally after: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
  • 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() and Client.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.
  • Cogs -> Suites: discord.py's concept of a cog is essentially the same as a Beymax suite. 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-0.0.1.tar.gz (27.0 kB view details)

Uploaded Source

Built Distribution

beymax-0.0.1-py3-none-any.whl (27.3 kB view details)

Uploaded Python 3

File details

Details for the file beymax-0.0.1.tar.gz.

File metadata

  • Download URL: beymax-0.0.1.tar.gz
  • Upload date:
  • Size: 27.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for beymax-0.0.1.tar.gz
Algorithm Hash digest
SHA256 56ef0c1bf946e67b2558bd3fc62807940b8cb48029abc5a9a2f86e3a879671b7
MD5 9a54c795b6ead670c84079efba399a88
BLAKE2b-256 82ff4be553fecbd3adb76f7919a53c8c781823ef2e3315aeb5705a649b563f9b

See more details on using hashes here.

File details

Details for the file beymax-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: beymax-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 27.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for beymax-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 988a07547475dc4b62a9665d45bc337d1459718b7d296d7bee24a250b09d90cd
MD5 a01498b402ecba7d6f3b47be22a4227b
BLAKE2b-256 0388758c564c6abfebabd0ac0e0c398e7d1d175a45f1bba20052c4ab6ef6e940

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page