Skip to main content

Encode objects in custom_ids.

Project description

Persistence

An extension for interactions.py that dynamically places and returns objects in and from Discord's custom_ids so you don't have to.

How it works

The most popular interactions.py extension, Wait-For is an easy and effective way to simplify complex component chains by preserving the objects used during interaction. However, this means that any components created before the bot restarts become unresponsive. This could be solved by saving all previous needed interaction details to the disk, but that may not be an ideal solution for everyone. Luckily, there is another option.

The solution

The solution, originally concieved and executed by Toricane, was to place information in Discord's custom_ids. In the vanilla library, this requires some on_component or on_modal logic. Enhanced simplifies this by adding startswith and regex args to the bot.component and bot.modal decorators. However, even this is more complicated than necessary.

Further abstraction

Interactions-Persistence further simplifies placing objects in custom_ids using the repr method from objects and evaluating them to return the right type. Using this ext is not only incredibly simple, but also reliable and lightweight. Taking a similar approach to Enhanced, Persistence uses on_component and on_modal listeners to identify and properly call persistent decorators.

Enjoy!

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

interactions-persistence-0.1.0.tar.gz (16.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

interactions_persistence-0.1.0-py3-none-any.whl (17.2 kB view details)

Uploaded Python 3

File details

Details for the file interactions-persistence-0.1.0.tar.gz.

File metadata

  • Download URL: interactions-persistence-0.1.0.tar.gz
  • Upload date:
  • Size: 16.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.13

File hashes

Hashes for interactions-persistence-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2fc6e542205561628c61525ec6f530af803a034d2f62b6a76b881f283dc8ed0c
MD5 65e8bd1e51f84dfb3ab5aa0399afd9e8
BLAKE2b-256 c49deba9353d1871fc7b8dc33d420ba4f13e89b41eb4b28fa6f43aec5443f8be

See more details on using hashes here.

File details

Details for the file interactions_persistence-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for interactions_persistence-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e6b004ee65a82e7004a42edab1a348535a0a3a6617004b6ddbe403703142ac84
MD5 569c2c56cf61aa112cebff44bc92979b
BLAKE2b-256 5374c5192a5a24e7814d7c30e24ca6854b4c70df468a6af7a8fc9f8f8290c136

See more details on using hashes here.

Supported by

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