Skip to main content

a collection of utils I use with discord.py

Project description

discord-ext-utils

a collection of utils I use with discord.py

This repo includes

Guide/wiki/docs

global view error handler

To use it, simply subclass our view class instead of discord.ui.View. (or if your using a modal, our modal class instead of discord.ui.Modal) After that, our subclass will call on_view_error (or on_modal_error) then view.on_error (or modal.on_error) in the case of an errorrrr.

global view interaction_check

To use it, simply subclass our view class instead of discord.ui.View. Our subclass will call bot.interaction_check (if it exists) which acts like view.interaction_check. If it returns True, then it will check view.interaction_check.

BaseConverter

We have a base converter class which allows you to easily make converters which work for slash, prefix, and hybrid cmds. Example:

class MyConverter(BaseConverter):
    async def handle(self, ctx_or_interaction, arg) -> str:
        # handle
        return ag

CodeblockConverter

CodeblockConverter is actually an typing.Annotated statement, which returns Codeblock (a dataclass with code and language). For the actual converter, see ActualCodeblockConverter.

Custom bot subclass

We have a custom bot subclass which you can subclass and use. It contains a re-populated session attribute, and a bot.load_extensions method which can either take a list of extensions or a folder which your extensions reside in. It will then load them, and if there is an error it will send it via logs. It also has a setup_logging method, which is auto-called when calling bot.run/start.

send_message

this helper func lets you easily send a message. It takes a pos-only arg which is the destination. This could be a context object, interaction, channel, member, webhook, or a messageable. It also takes every kwarg any send method takes, and if a certain method does not support a kwarg it will drop it.

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

discord-ext-utils-0.0.1.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

discord_ext_utils-0.0.1-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file discord-ext-utils-0.0.1.tar.gz.

File metadata

  • Download URL: discord-ext-utils-0.0.1.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0

File hashes

Hashes for discord-ext-utils-0.0.1.tar.gz
Algorithm Hash digest
SHA256 5213dc4c1df1af87dada033d40476449fe8f37217b66e54e45142bffbc3f6fa7
MD5 c0c1ecd3c129c2eb7f3e512d8cb69cad
BLAKE2b-256 159d0c933d5b9c1551084ebd28aea88b7dc0a0c970a3153343d70060730eb39f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for discord_ext_utils-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d4b78bff54c6d8dc7789b74eeff1c7565cbc12c62b0a5aa2c4d6847825aef7dd
MD5 88a03dfcf98668e84ee26ec59e730326
BLAKE2b-256 ee7ccbb0a59cad91e723ffdf233a2334d0fe2bfb47e8235c8ee91a9513a88e00

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