dpy-components
This lib adds components support for discord.py.
Please note this is beta yet.
Example
import os
from discord.ext import commands, components
bot = commands.Bot("c ")
bot.load_extension("discord.ext.components")
@bot.event
async def on_ready():
print('We have logged in as {0.user}'.format(bot))
@bot.command()
async def test(ctx, button_label, hidden: bool):
await components.send(ctx, "Click this", components=[components.Button(button_label, name="button1")])
cmp = await bot.wait_for("button_click", check=lambda c: c.name == "button1")
await cmp.send(f"You clicked {button_label}.", hidden=hidden)
bot.run(os.getenv("token"))
Reference
ButtonType
Represents button type.
primary,primary_cta,blue,blurple
Represents 1.
success,primary_success,green
Represents 2.
secondary,gray,grey
Represents 3.
danger,destructive,red
Represents 4.
link,url
Represents 5.
components.send
This function is a coroutine. Send message with components.
components.send(channel: discord.abc.Messageable, content=None, *, tts=False, embed=None, file=None,
files=None, delete_after=None, nonce=None,
allowed_mentions=None, reference=None,
mention_author=None, components=[])
channnel: Channel to send the message.
content..mention_author: Same as discord.abc.Messageable.send.
components: Components to attach to the message.
If you want to use multi row components, please specify 2D list.
components.reply
This function is a coroutine.
An utility function for replying message.
Same as:
await send(target.channel, *args, reference=target.to_reference(), **kwargs)
components.Button
Represents a button in component.
label: Label for the button.
custom_id|name: Custom id for the button.
url: URL for the button.
style: Style for the button.
Pass values of Button Styles, or ButtonType.
emoji: Emoji for the button.
enabled: Whether the button is enabled.
Properties
.disabled: Same as not self.enabled.
on_button_click(cmp: ButtonResponse)
Fires when user clicked button.
ButtonResponse
Represents a button response.
Do not initialize this class directly.
id: ID of the interaction.
application_id: Application ID of the interaction.
guild: Guild of the interaction.
channel: Channel of the interaction.
message: Message of the interaction.
member: Member who pressed the button.
token: Token of the interaction.
custom_id|name: Custom ID of the button.
ButtonResponse.send
This function is a coroutine.
Responds interaction.
ButtonResponse.send(
content=None, *,
embed=None,
embeds=[],
allowed_mentions=None,
tts=False,
hidden=False
)
content...tts: Same as discord.abc.Messageable.send.
hidden: Hide the message or not.
ButtonResponse.defer_source
This function is a coroutine.
ACK an interaction with DeferredChannelMessageWithSource(5).
The user sees a loading state.
ButtonResponse.defer_update
This function is a coroutine.
ACK an interaction with DeferredUpdateMessage(6).
The user doesn't see a loading state.
Metadata
Release files for dpy-components 0.4.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dpy_components-0.4.2-py3-none-any.whl | Python 3 | none | any | Details for dpy_components-0.4.2-py3-none-any.whl |
Release files / dpy_components-0.4.2-py3-none-any.whl
| Download URL | dpy_components-0.4.2-py3-none-any.whl |
|---|---|
| Size | 9.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
942fbff7ac6bc8ec665ed6578ee5328a4cd0ece09a8426d99eb8ef60f523058c
|
|
BLAKE2b-256 checksum How to use checksums |
68bb3f927732dd627de6b65ca078044a391df4e715a4c0fd2341771d48764fec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/54.1.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2
|
Security for dpy-components 0.4.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.