我正在尝试创建一个发送带有两个按钮的嵌入的事件,一个处理不同的命令,另一个在您不需要帮助时单击,以便清除提及和嵌入。
这是我刚刚得到的代码:
@client.event
async def on_message(message):
s = client.get_command("yeet")
if client.user.mentioned_in(message):
txt = discord.Embed(title="What's up? You need some help?",
color=discord.Colour.dark_gold())
txt.add_field(name="Press the `Help` button if you want to see every command that i have",
value="Press the `Nvm` button if you didn't mean to mention me")
g = await message.channel.send(
embed=txt,
components=[[Button(style=2, label="Help"), Button(style=3, label="Nvm")]]
)
try:
hel = await client.wait_for("button_click", timeout=120)
if hel.component.label == "Help":
await client.process_commands(s)
elif hel.component.label == "Nvm":
await hel.respond(content="Oh okey no problem", ephemeral=False)
except TimeoutError:
time = discord.Embed(title="You're out of time try again", colour=discord.Colour.dark_magenta())
await g.edit(embed=time)
问题是如果我按下“帮助”按钮,我会收到此错误
Traceback (most recent call last):
File "C:\Users\Nutzer\PycharmProjects\Dipps\venv\lib\site-packages\discord\client.py", line 333, in _run_event
await coro(*args, **kwargs)
File "C:/Users/Nutzer/PycharmProjects/Dipps/Main/Test Files/button commands.py", line 76, in on_message
await client.process_commands(s)
File "C:\Users\Nutzer\PycharmProjects\Dipps\venv\lib\site-packages\discord\ext\commands\bot.py", line 936, in process_commands
if message.author.bot:
AttributeError: 'Command' object has no attribute 'author'