Skip to main content

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,
  • Uses an intuitive dataclass-like syntax to create innately persistent components,
  • custom_id matching, conversion, and creation are automated for you.

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

disnake_compass-1.0.0.tar.gz (44.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

disnake_compass-1.0.0-py3-none-any.whl (57.8 kB view details)

Uploaded Python 3

File details

Details for the file disnake_compass-1.0.0.tar.gz.

File metadata

  • Download URL: disnake_compass-1.0.0.tar.gz
  • Upload date:
  • Size: 44.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.6 Linux/5.10.16.3-microsoft-standard-WSL2

File hashes

Hashes for disnake_compass-1.0.0.tar.gz
Algorithm Hash digest
SHA256 c1cfaf0ac3ca806838929de0c56041692a7be6378770584ae5fdb66d4a57b4e1
MD5 861d77f5ee863e02ea18d06b5e89aa02
BLAKE2b-256 9f00c60a30c16e68b45830e6054f6bbd92306df0d1407a4eace37605bac362a0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: disnake_compass-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 57.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.6 Linux/5.10.16.3-microsoft-standard-WSL2

File hashes

Hashes for disnake_compass-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f2b183f399f704bf9e9d850d5c28f286b987debd63b9d4ed80f86547fed79d03
MD5 e32d278d299e6eaf818d96b6699843c5
BLAKE2b-256 623966cdb104ffd7f91df8f589e6d36ceda75aecd6e7124cca517214e8048638

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