10

Github GitHub - kiki7000/discord.py-components: An unofficial library for discor...

 3 years ago
source link: https://github.com/kiki7000/discord.py-components
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

discord-components

An unofficial library for discord components (under-development)

Welcome!

Discord components are cool, but discord.py will support it on version 2.0. It is hard to wait, so we made a third-party library for using components such as buttons or selects! We're currently developing this library, so it has a lot of bugs. But it has enough features to make the components easy to use :)

This project is open source star.

Also, there is an official discord server, so if you have a question, feel free to ask it on this server.

Features

  • You can use discord components and handle interactions easily!
  • Methods based on discord.py.
  • Supports discord.ext.commands, and going to support discord-py-slash-command.

The official docs is not finished so for now you can use this The docs could contain many grammatic errors, spelling mistakes, and typos because I am not a native English speaker. So if there is a problem on the docs, contact me or create an issue.

Install

pip install --upgrade discord-components

Example

from discord.ext.commands import Bot
from discord_components import DiscordComponents, Button

bot = Bot(command_prefix = "your prefix")


@bot.event
async def on_ready():
    DiscordComponents(bot)
    print(f"Logged in as {bot.user}!")


@bot.command()
async def button(ctx):
    await ctx.send(
        "Hello, World!",
        components = [
            Button(label = "WOW button!")
        ]
    )

    interaction = await bot.wait_for("button_click", check = lambda i: i.component.label.startswith("WOW"))
    await interaction.respond(content = "Button clicked!")


bot.run("your token")

You can see more examples here.

License

This project is under the MIT License.

Contribute

Anyone can contribute to this by forking the repository, making a change, and create a pull request!

But you have to follow these to PR.

Thanks to

  • Minibox - Button API explanation when the button docs were only for beta users.
  • Lapis - Suggested a method to change every class's property.
  • And to all contributors!

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK