如何添加这些带有图像的按钮?

yh2wf1be  于 2021-08-20  发布在  Java
关注(0)|答案(1)|浏览(408)

有人能帮我添加这些带有图片的按钮吗?我正在尝试,但无法在python中为discord bot添加图像。在这里,我留下了我的意思的截图:

这是我的密码

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("")
tuwxkamq

tuwxkamq1#

试试看:

components = [
    Buttom(..., emoji='<emoji-name:emoji-id>'),
    ...
]

相关问题