discord.py-添加反作用作为命令的一部分



我正在编写一个自定义帮助命令,该命令将嵌入DM发送给用户,一切都很好。作为命令的一部分,我试图让机器人对命令消息做出反应,但我无法让它工作,我已经阅读了文档,但似乎仍然无法让它作为命令的组成部分做出反应。以下是我试图实现的目标:

@client.command(pass_context=True)
async def help(ctx):
# React to the message

author = ctx.message.author
help_e = discord.Embed(
colour=discord.Colour.orange()
)
help_e.set_author(name='The bot's prefix is !')
help_e.add_field(name='!latency', value='Displayes the latency of the bot', inline=False)
help_e.add_field(name='!owo, !uwu, !rawr', value='Blursed commands', inline=False)
await author.send(embed=help_e)```

您可以使用message.add_reaction(),也可以使用ctx.message向消息添加反应。以下是您可以做的:

@client.command(pass_context=True)
async def help(ctx):
# React to the message
await ctx.message.add_reaction('✅')
author = ctx.message.author
help_e = discord.Embed(
colour=discord.Colour.orange()
)
help_e.set_author(name='The bot's prefix is !')
help_e.add_field(name='!latency', value='Displayes the latency of the bot', inline=False)
help_e.add_field(name='!owo, !uwu, !rawr', value='Blursed commands', inline=False)
sent_embed = await author.send(embed=help_e)

最新更新