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-1.0.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-1.0.0-py3-none-any.whl (17.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: interactions-persistence-1.0.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-1.0.0.tar.gz
Algorithm Hash digest
SHA256 3ee618960dae26c1972781b9229f6391000d197734403fb96ba0a42bc98a164b
MD5 10147ae1ec25e47b3a934ecd376f8fca
BLAKE2b-256 f971ea241322a8d93ca88de8eedc468f253fe740621654c258f52910b5659f1e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for interactions_persistence-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8b9cfd412c765862e250f864c35120e8a0ac5feba61d27875e2df2bf09a5bab4
MD5 6a3913ef8579e84b6a7500c362503aac
BLAKE2b-256 85d8f7a4aab5b2983a60305e6c38166279d901b771d69d3bbe61b9a45f903adb

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