Skip to main content

Encode json in custom_ids.

Project description

Persistence

PyPI - Downloads

An extension for interactions.py that dynamically places and returns objects in and from Discord's custom_ids so you don't have to. Check the wiki to learn how to use it!

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 conceived 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 json and allowing str, int, float, dict and list. The extension also encrypts custom_ids so it isn't obvious what they are doing. 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-2.1.0.tar.gz (20.2 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-2.1.0-py3-none-any.whl (22.2 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for interactions-persistence-2.1.0.tar.gz
Algorithm Hash digest
SHA256 7ebff7d1c7b8dfe926f288011339d2ee5795170d0e884622ec3d14494d8f6cf8
MD5 6b527279527a47a316d8546a44db21db
BLAKE2b-256 ba0652dfce76bcbe19958ee13c231e9a427bdd2108e4accab3dec9511b0487c0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for interactions_persistence-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1fd418f5f5c5b18027da27eddc18451f9dd6ea01749596bdd5bffffb83d9954f
MD5 20baa4939a59de53250c7b3800450457
BLAKE2b-256 795651ed5e8d4f1c0151b992218f9b7b3036581022303d235f92383a12d103bb

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