Skip to main content

Discord Components V2 for discord.py

Project description

.----..-.  .-.    .---.  .----. .-.   .-..----.  .----. .-. .-..----..-. .-. .---.  .----.
| {}  }\ \/ /    /  ___}/  {}  \|  `.'  || {}  }/  {}  \|  `| || {_  |  `| |{_   _}{ {__  
| .--'  }  {     \     }\      /| |\ /| || .--' \      /| |\  || {__ | |\  |  | |  .-._} }
`-'     `--'      `---'  `----' `-' ` `-'`-'     `----' `-' `-'`----'`-' `-'  `-'  `----' 

py-components is a lightweight Python library that provides helpers for building Discord Components (Buttons, Select Menus, Action Rows) for use with discord.py.

It is designed to simplify the creation and handling of Discord UI components while keeping the API clean, minimal, and easy to extend.


Features

  • Simple Discord Components V2 wrapper
  • Easy-to-use Button, Select Menu, and Action Row builders
  • Async-friendly design
  • Clean and readable API
  • Built to integrate with discord.py

Installation

pip install py-components

Requirements

  • Python 3.10+
  • discord.py (latest recommended)
  • aiohttp

Quick Start

Creating a Button

from py_components import Button, ActionRow

button = Button(
    label="Click Me",
    style="primary",
    custom_id="click_me_button"
)

row = ActionRow(components=[button])

Handling Interactions

from py_components import Button

button = Button(
    label="Hello",
    style="success",
    custom_id="hello_button"
)

async def handle_interaction(interaction):
    await interaction.response.send_message("You clicked the button!")

Components

Buttons

Supported styles:

  • primary
  • secondary
  • success
  • danger
Button(
    label="Delete",
    style="danger",
    custom_id="delete_btn"
)

Select Menus

from py_components import SelectMenu

menu = SelectMenu(
    custom_id="menu_example",
    options=[
        {"label": "Option 1", "value": "opt1"},
        {"label": "Option 2", "value": "opt2"}
    ]
)

Action Rows

Used to group components together.

from py_components import ActionRow

row = ActionRow(components=[button, menu])

Example Usage

from py_components import Button, ActionRow, SelectMenu

button = Button(
    label="Click Me",
    style="primary",
    custom_id="btn_1"
)

menu = SelectMenu(
    custom_id="menu_1",
    options=[
        {"label": "Red", "value": "red"},
        {"label": "Blue", "value": "blue"}
    ]
)

row = ActionRow(components=[button, menu])

Roadmap

  • Modal support
  • Full discord.py integration helpers
  • Prebuilt UI templates
  • Advanced component event handling
  • Stronger typing + validation
  • More Discord component types support

Project Structure

py-components/
├── py_components/
│   ├── __init__.py
│   ├── buttons.py
│   ├── select.py
│   └── components.py
├── README.md
├── pyproject.toml
└── LICENSE

License

MIT License


Notes

This library is a helper layer for building Discord UI components more efficiently. It does not replace discord.py, but extends it with easier component creation utilities.

--

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

discordpycomponents-0.2.2.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

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

discordpycomponents-0.2.2-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file discordpycomponents-0.2.2.tar.gz.

File metadata

  • Download URL: discordpycomponents-0.2.2.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for discordpycomponents-0.2.2.tar.gz
Algorithm Hash digest
SHA256 21fa02d6bdf42eb143940d3ffcd81041266427628009cc8c9069c4d8ddd331a4
MD5 2850d7fe3198d9c9afd4b9f41428cef2
BLAKE2b-256 18667c156ae45162907222f05df681b06d3739e81263a1e0b2363edd24c2779c

See more details on using hashes here.

Provenance

The following attestation bundles were made for discordpycomponents-0.2.2.tar.gz:

Publisher: publish.yml on 2gm49/py-components

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file discordpycomponents-0.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for discordpycomponents-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7c9cd61124300b8ac14b269f5e1a70f0becf271ca49a36a051416c5b938f6a1f
MD5 e2e7a94635a39a154863b0b9d0201a67
BLAKE2b-256 a8a545b99bad8bd5484a173e6f2621ec246be244f61f23d0d5692b6807c2c9ce

See more details on using hashes here.

Provenance

The following attestation bundles were made for discordpycomponents-0.2.2-py3-none-any.whl:

Publisher: publish.yml on 2gm49/py-components

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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