helish88 / discord.py-components

unofficial library for discord components(on development)

Home Page:https://pypi.org/project/discord-components/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

discord.py-components

Build Status PyPI version Documentation Status

An unofficial library for Discord components. (on development)

Installation

pip install --upgrade discord-components

Example

from discord import Client
from discord_components import DiscordComponents, Button, ButtonStyle, InteractionType

bot = Client()

@bot.event
async def on_ready():
    DiscordComponents(bot)

@bot.event
async def on_message(msg):
    if msg.author.bot:
        return

    await msg.channel.send(
        "Content",
        components=[
            Button(style=ButtonStyle.blue, label="Blue"),
            Button(style=ButtonStyle.red, label="Red"),
            Button(style=ButtonStyle.URL, label="url", url="https://example.org"),
        ],
    )

    res = await bot.wait_for("button_click")
    if res.channel == msg.channel:
        await res.respond(
            type=InteractionType.ChannelMessageWithSource,
            content=f'{res.component.label} clicked'
        )


bot.run("token")

Docs

The docs can contain lot of spelling mistakes, grammar errors so if there is a problem please create an issue!

Features

  • Send, edit Discord components.
  • Get components interact event!
  • Supports discord.py command extension.

Helps

  • Minibox - Button API explanation
  • Lapis - Told me how to replace a property

About

unofficial library for discord components(on development)

https://pypi.org/project/discord-components/

License:MIT License


Languages

Language:Python 100.0%