首先,让我们更清楚地了解一下这段代码:
class View(discord.ui.View):
def __init__(self):
super().__init__()
@discord.ui.button(label='Confirm', style=discord.ButtonStyle.green)
async def asdf(self, interaction: discord.Interaction, button: discord.ui.Button):
await interaction.response.edit_message(content="whae",embed=None,view=None)
@bot.tree.command(name="suggest", description="Make a suggestion with this command.")
async def hello(interaction: discord.Interaction, title: str, description: str):
embed = discord.Embed(title=f"Is this information correct?", description=f"sdfsdfsdfsd", color=discord.Colour.random())
embed.set_thumbnail(url=f"{interaction.user.avatar.url}")
embed.add_field(name=f"Title", value=f"{title}", inline=False)
embed.add_field(name="Description", value=f"{description}")
embed.set_footer(text=f"USER ID: {interaction.user.id}")
await interaction.response.send_message(embed=embed, view=View(), ephemeral=True)
因此,这些变化:
-
(对我来说最重要的变化)不要把交互称为ctx,这真的很令人困惑。不一致交互就是交互,命令。上下文是ctx。不管怎样,它都有效,但看起来丑陋而不切实际。
-
在编辑消息函数中,我对要更改的内容进行了声明
就是这样。