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.23.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.23-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: discordpycomponents-0.2.23.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.23.tar.gz
Algorithm Hash digest
SHA256 a3da80170c89b60864740f4148dd700a99548d47ee504cd8c3402ccd614b2d2b
MD5 f2e767beb88921eb33648b1dbe8c5d90
BLAKE2b-256 cbf99809b7a0a93b02d18e35abb3fc1b133d7607f09302722cf5899f0e4f32fa

See more details on using hashes here.

Provenance

The following attestation bundles were made for discordpycomponents-0.2.23.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.23-py3-none-any.whl.

File metadata

File hashes

Hashes for discordpycomponents-0.2.23-py3-none-any.whl
Algorithm Hash digest
SHA256 4ac23f961c92a0c31fd8e6dbfd2d169dfd4a491158670d8aeda972c853e1cdbb
MD5 c1aa949aa0220716d8a56f8ef403ccad
BLAKE2b-256 efd089212fc51e0e028bb3e1ca3f196c18db072bfb4f778f28d31b1164db1ac4

See more details on using hashes here.

Provenance

The following attestation bundles were made for discordpycomponents-0.2.23-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