Flare
A stateless component manager for hikari with a type-safe API.
Features:
- buttons, select menus, and modals
- easy and powerful API for simple interactions
- saves data between bot restarts by utilizing the component's custom id
If you want to create complex component interactions hikari-miru may be a better choice.
Installation
pip install hikari-flare
Links
Example
import flare
import hikari
@flare.button(label="Test Button", style=hikari.ButtonStyle.PRIMARY)
async def test_button(
ctx: flare.MessageContext,
) -> None:
await ctx.respond(content="Hello World!")
@flare.button(label="State Button", style=hikari.ButtonStyle.PRIMARY)
async def state_button(
ctx: flare.MessageContext,
# Args and kwargs are used for state.
number: int,
) -> None:
await ctx.respond(content=f"The number is: {number}")
bot = hikari.GatewayBot("...")
flare.install(bot)
@bot.listen()
async def buttons(event: hikari.GuildMessageCreateEvent) -> None:
# Ignore other bots or webhooks pinging us
if not event.is_human:
return
me = bot.get_me()
# If the bot is mentioned
if me.id in event.message.user_mentions_ids:
# Set custom state for components that need it
row = await flare.Row(test_button(), state_button(5))
message = await event.message.respond("Hello Flare!", component=row)
bot.run()
The API can also be accessed at a lower level if components need typed attributes.
class Button(flare.Button):
a: int
b: str
async def callback(self, ctx: flare.Context) -> None:
typing_extensions.reveal_type(self.a) # int
typing_extensions.reveal_type(self.b) # str
await ctx.respond("Hello flare!")
Converters
Converters allow you to serialize and deserialize types. Here in an example of an int converter.
Converters for int, str, typing.Literal, and enum.Enum are built in.
class IntConverter(Converter[int]):
async def to_str(self, obj: int) -> str:
return str(obj)
async def from_str(self, obj: str) -> int:
return int(obj)
flare.add_converter(
int, # The typehint this converter is used for.
IntConverter # The converter class.
)
Metadata
Release files for hikari-flare 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| hikari-flare-0.1.3.tar.gz | 33.7 kB | Without provenance | Details for hikari-flare-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hikari_flare-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for hikari_flare-0.1.3-py3-none-any.whl |
Total release size: 72.2 kB
Release files / hikari-flare-0.1.3.tar.gz
| Download URL | hikari-flare-0.1.3.tar.gz |
|---|---|
| Size | 33.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a4410b7a0942a5dd3615f925d49b5cb40cc1ff3b383ca2ebd36ee2f012a69bce
|
|
BLAKE2b-256 checksum How to use checksums |
aac2e93dc04a4d1336826da3a16c7270837e479bd83ee6ccb9a8003fc7a4c319
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.13
|
Release files / hikari_flare-0.1.3-py3-none-any.whl
| Download URL | hikari_flare-0.1.3-py3-none-any.whl |
|---|---|
| Size | 38.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
837938068daf10c3199a8e754ed51e410093d79879158c5b29ad395bd083a8d3
|
|
BLAKE2b-256 checksum How to use checksums |
78b0d9e6e3b1e8a43f4d5e36a4c92933130d221dc2b5f704b601668e77fa975a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.13
|
Security for hikari-flare 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.