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.2.3.tar.gz (20.6 kB view hashes)

Uploaded Source

Built Distribution

interactions_persistence-2.2.3-py3-none-any.whl (22.6 kB view hashes)

Uploaded Python 3

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