所以我和我的朋友有一個嵌入,
@client.event
async def on_message(message):
if message.content.lower().startswith("!help"):
HelpEmbed = discord.Embed(
title="Help screen",
description=
"Here is you can find instructions of how to use the bot!",
color=discord.Colour.blue())
HelpEmbed.add_field(
name="Game Commands",
value=
"These are commands to do stuff in the game, use !GameCMDS to see all commands relate to the game",
inline=False)
HelpEmbed.add_field(
name="Server commands",
value=
"These are commands to do stuff with the server. Use !ServerCMDS to see all commands related to the server",
inline=False)
HelpEmbed.set_thumbnail(
url=
"https://images.unsplash.com/photo-1477959858617-67f85cf4f1df?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=1244&q=80"
)
await message.channel.send(embed=HelpEmbed)
我們想向它添加按鈕,但是所有教程都不起作用。我的朋友也不知道怎么做,所以如果你知道請告訴我,如果你能告訴我如何添加頁腳,因為HelpEmbed.set_footer不起作用。謝謝!
uj5u.com熱心網友回復:
看看 discord-ineraction,一個用于 discord 組件(按鈕、選擇、斜線命令等)的 Python 庫, GitHub,Docs
首先,安裝庫
$ pip install -U discord-py-interactions
根據檔案,您可以使用create_button:
from discord_slash.utils.manage_components import create_button, create_actionrow
from discord_slash.model import ButtonStyle
# ...
buttons = [
create_button(
style=ButtonStyle.green,
label="A Green Button"
),
]
action_row = create_actionrow(*buttons)
await message.channel.send(embed=HelpEmbed, components=[action_row])
至于頁腳,你可以設定embed.set_footer()
embed.set_footer(text="我的頁腳")
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/342466.html
