Components V2 helper for Discord bots
Project description
UICord
A UI helper library for pycord that makes Discord's Components V2 simple to work with.
[!CAUTION] This project is a work in progress. Contributions are very welcome!
Features
- Clean wrappers around every Components V2 primitive (Button, Select, Container, Section, MediaGallery, …)
ViewandModalsubclasses with built-in owner-checking and auto-reload@interactiondecorator with automatic error reporting to developersUIString- astrsubclass with pluggable i18n viastate.translator_functionlang=keyword onViewandModalfor per-instance translations- Graceful pycord 2.7 / 2.8 compatibility shims (
MediaGalleryItem,Checkbox,CheckboxGroup)
Installation
pip install uicord
Requires pycord ≥ 2.7.
For Checkbox / CheckboxGroup support, use pycord ≥ 2.8.
Quick Start
import discord
from discord.ext import commands
import uicord
bot = commands.Bot(command_prefix="!")
@bot.slash_command()
async def demo(ctx):
view = uicord.View(owner=ctx.author.id)
btn = uicord.Button("Click me!", color=uicord.Colors.Blue)
view.add(ActionRow(btn))
@uicord.interaction(component=btn)
async def on_click(ictx):
await ictx.respond("You clicked it!", ephemeral=True)
await ctx.respond("Here you go:", view=view)
bot.run("TOKEN")
Internationalisation / Localisation
from uicord import state, UIString, View
# Plug in any translation backend
state.translator_function = lambda text, lang: my_i18n(text, lang)
# Translate at construction time
greeting = UIString("hello.world", lang="fr")
# Or let the View handle it - view._("key") returns a UIString in view.lang
view = View(lang="ja")
label = view._("btn.confirm") # → translated to Japanese
Components at a Glance
| Class | Description |
|---|---|
View |
Main component container with owner-check and reload |
Modal |
Input/output modal with label helpers |
Button |
Interactable button |
Toggle |
Stateful on/off button |
RadioButtons |
Radio-button group |
RadioButtonOption |
Option inside "Radio buttons" component |
Choices |
Select / drop-down menu |
ActionRow |
Manual row layout |
Container |
Component container |
Section |
Section block (pycord ≥ 2.7) |
Separator |
Visual divider |
Thumbnail |
Inline thumbnail |
MediaGallery |
Media gallery block (pycord ≥ 2.7) |
MediaGalleryItem |
Item inside a MediaGallery (pycord ≥ 2.7) |
Text |
Text display |
GridItem |
Item inside a Grid |
Grid |
Grid display |
Checkbox |
Single checkbox (pycord ≥ 2.8) |
CheckboxGroup |
Group of checkboxes (pycord ≥ 2.8) |
UIString |
Translatable string subclass |
Full API reference → uicord.readthedocs.io
Contributing
This project genuinely needs contributors. Bug reports, feature requests, and pull requests are all appreciated.
Originally made for you and the community by H1387Lmao ♥ - open-source, no license. Please keep it that way.
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
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 uicord-5.0.3.tar.gz.
File metadata
- Download URL: uicord-5.0.3.tar.gz
- Upload date:
- Size: 16.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.12.1.2 requests/2.32.5 setuptools/81.0.0 requests-toolbelt/1.0.0 tqdm/4.67.3 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d2068257a21e82eeaf47478bf3d094db91728727b2051e99a0226864025094e4
|
|
| MD5 |
cff463f175e7298c2a59709130208a60
|
|
| BLAKE2b-256 |
a13937010e826a905348d710105a059c69288aea6f2dae66603dcedf1df29258
|
File details
Details for the file uicord-5.0.3-py3-none-any.whl.
File metadata
- Download URL: uicord-5.0.3-py3-none-any.whl
- Upload date:
- Size: 19.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.12.1.2 requests/2.32.5 setuptools/81.0.0 requests-toolbelt/1.0.0 tqdm/4.67.3 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a41e060b032e7bd2d1c943359b39cde14b00c1376e0ca3b6c631a1873a74a909
|
|
| MD5 |
2ee6bee802877a1abbf4efa27e9ccc19
|
|
| BLAKE2b-256 |
f1e94ed3a01d4832834b6ffb2d5959b985f6656c4f9d864404238bd4e93c35f5
|