An extension for disnake aimed at making component interactions with listeners somewhat less cumbersome.
Project description
NOTE
disnake-compass
An extension for disnake aimed at making component interactions with listeners somewhat less cumbersome.
Requires disnake version 2.10.0 or above and python 3.10.0 or above.
Key Features
- Smoothly integrates with disnake,
- Intuitive dataclass-like syntax to declare component classes,
- Fully stateless and persistent by permanently storing state inside custom ids,
- Custom id matching, parsing, conversion and creation are all managed for you,
- Highly customisable!
Installing
Python 3.10 or higher and disnake 2.10.0 or higher are required
To install the extension, run the following command in your command prompt/shell:
# Linux/macOS
python3 -m pip install -U disnake-compass
# Windows
py -3 -m pip install -U disnake-compass
It can then be imported as
import disnake_compass
Examples
A very simple component that increments its label each time you click it can be written as follows:
import disnake
from disnake.ext import commands
import disnake_compass
bot = commands.InteractionBot()
manager = disnake_compass.get_manager()
manager.add_to_client(bot)
@manager.register
class MyButton(disnake_compass.RichButton):
count: int
async def callback(self, interaction: disnake.MessageInteraction[disnake.Client]) -> None:
self.count += 1
self.label = str(self.count)
await interaction.response.edit_message(components=self)
@bot.slash_command()
async def test_button(interaction: disnake.CommandInteraction[disnake.Client]) -> None:
component = await MyButton(label="0", count=0).as_ui_component()
await interaction.send(components=component)
bot.run("TOKEN")
For extra examples, please see the examples folder.
To-Do
- Implement modals,
- Improve Cog support by somehow injecting the cog instance,
- Contribution guidelines,
Contributing
Any contributions are welcome, feel free to open an issue or submit a pull request if you would like to see something added. Contribution guidelines will come soon.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file disnake_compass-1.1.0.tar.gz.
File metadata
- Download URL: disnake_compass-1.1.0.tar.gz
- Upload date:
- Size: 199.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
72ad4dd72f74fbb33d8720c497f4195c4c107d349910387557af56296be0b32e
|
|
| MD5 |
85e060e3d1318ba315bdcce8e7f0f579
|
|
| BLAKE2b-256 |
a73d4583225760b956f88ebec0e696fe39ed4328a5d968dd8a3adb5ca5299748
|
Provenance
The following attestation bundles were made for disnake_compass-1.1.0.tar.gz:
Publisher:
release.yml on DisnakeCommunity/disnake-compass
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
disnake_compass-1.1.0.tar.gz -
Subject digest:
72ad4dd72f74fbb33d8720c497f4195c4c107d349910387557af56296be0b32e - Sigstore transparency entry: 737927112
- Sigstore integration time:
-
Permalink:
DisnakeCommunity/disnake-compass@64566cb92b236f2cec2534ed309e280284cbe415 -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/DisnakeCommunity
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@64566cb92b236f2cec2534ed309e280284cbe415 -
Trigger Event:
push
-
Statement type:
File details
Details for the file disnake_compass-1.1.0-py3-none-any.whl.
File metadata
- Download URL: disnake_compass-1.1.0-py3-none-any.whl
- Upload date:
- Size: 59.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9b19dc1558005256bf55590a94e40a40bf77d664c7811f264aebb2dd7af0a9a5
|
|
| MD5 |
b86536e8a22e732ca19602ba8cb93e60
|
|
| BLAKE2b-256 |
0eac43d9502b349924e576673180d0df8a89164629881c599b9a3812b55bf8cf
|
Provenance
The following attestation bundles were made for disnake_compass-1.1.0-py3-none-any.whl:
Publisher:
release.yml on DisnakeCommunity/disnake-compass
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
disnake_compass-1.1.0-py3-none-any.whl -
Subject digest:
9b19dc1558005256bf55590a94e40a40bf77d664c7811f264aebb2dd7af0a9a5 - Sigstore transparency entry: 737927121
- Sigstore integration time:
-
Permalink:
DisnakeCommunity/disnake-compass@64566cb92b236f2cec2534ed309e280284cbe415 -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/DisnakeCommunity
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@64566cb92b236f2cec2534ed309e280284cbe415 -
Trigger Event:
push
-
Statement type: