A UI kit containing reusable, dynamic, and intuitive views for Discord bots.
Project description
😻 Bot UI Kitty
A collection of reusable, dynamic, and intuitive Discord UI views, built on top of Pycord's Bot UI Kit.
This project was originally created for personal use in my (way too many) Discord bots, but I decided to make it more easily accessible just in case other bot developers find it helpful. 💜
Currently, the only supported Discord library is Pycord, because that's the one that most of my bots happen to use. I'm planning to extend support to other libraries too, but I'm not sure when I'll be able to make the time to do so. 📚 In the meantime, if you're using a different library, check out my other utility kit for Discord bots – Botstrap!
Contributions to this project are very welcome, as long as they pass all the checks to keep it green and healthy. ✅
Installation
pip install -U bot-ui-kitty
Note: Python 3.10 is required (because Pycord doesn't officially support Python 3.11... yet.)
For Development
git clone https://github.com/nuztalgia/bot-ui-kitty.git
cd bot-ui-kitty
pip install -e .
This will create an editable installation of bot-ui-kitty
in your current
environment. Any changes you make to the code will immediately take effect, so
using a virtual env is highly recommended!
Available Views
Dynamic Select
This view is designed to handle any use case that calls for selecting a single item from a sequence of possible options. It'll automatically choose to display either a row of buttons, a dropdown menu, or a combination of both (to emulate pagination) depending on the number of options you throw at it! 🤹
-
Example 1: Choose your starter Pokemon! (3 options)
Bonus: After clicking the 💧 Squirtle button...
number = await uikitty.dynamic_select( ctx, content="Choose your starter Pokemon!", **{"🌱 Bulbasaur": 1, "🔥 Charmander": 4, "💧 Squirtle": 7}, ) await ctx.edit(content=f"Your Pokemon's number is **#00{number}**!", view=None)
-
Example 2: What time is it, Mr. Wolf? (24 options)
This selection appears as a dropdown menu... but no matter what time it is, this particular wolf is always hungry! (Click to see spoilers.)
time = await uikitty.dynamic_select( ctx, *[f"{str(i).zfill(2)}:00" for i in range(24)], select_placeholder="What time is it, Mr. Wolf?", ) await ctx.edit(content=f"It's ~~{time}~~ **DINNER TIME!!!**", view=None)
-
Example 3: I heard you like chemistry... (119 options)
This is where things get interesting! ✨
- When you pass more than 25 options into a Dynamic Select view, they'll be evenly divided into "pages".
- The options for the current page are displayed in the dropdown menu.
- You can change the current page by clicking the << and >> buttons.
Here's what this example looks like on the first page, middle page, and last page. Notice that the << button is disabled on the first page, the >> button is disabled on the last page, and the center button is always disabled.
When you select an option in the dropdown, the center button will light up, allowing you to confirm your choice.
element = await uikitty.dynamic_select( ctx, embed=Embed(title="Select an element to learn more about it!", color=color), **elements_data, ) embed = Embed( title=element["name"], description=element["summary"], url=element["source"], ) await ctx.edit(embed=embed, view=None)
Note:
elements_data
in the above snippet is sourced from Bowserinator/Periodic-Table-JSON.
More types of views will be coming soon. Watch this space! 👀
License
Copyright © 2022 Nuztalgia. Released under the Apache License, Version 2.0.
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
Hashes for bot_ui_kitty-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8b30539060615f072a092553aca3e74fa4df8b2e312e056492ecb4eaf9614ddb |
|
MD5 | 10ddd91db26c4df7404a2a747ae8c2ec |
|
BLAKE2b-256 | 0af1ba18bfa29e62a66224bebf1f276ce6781621e2a5105d70d17d5c792cdd4c |