如何获取我在 discord py 中用命令回复的消息的 ID?

How to get an ID of the message I replied with command to in discord py?

所以我有代码可以对具有特定 ID 的消息添加反应。但我想这样做,如果我将使用此命令回复消息,机器人将获得我已回复的消息的 ID 并对其做出反应。 如果您有兴趣,可以查看我的“添加反应”代码。我是 python 的超级新手,甚至是 discord 机器人的新手,如果这是一个愚蠢的问题,我深表歉意。

@bot.command()
async def heart(ctx, msgid):
    ctx.message.id = msgid
    #await ctx.reply("Here's your reaction")
    await ctx.message.add_reaction("")
@bot.command
async def reply(ctx, *, args = None):
    await args.add_reaction(emoji='')

用法:回复messageid

如果我理解正确的话,您希望您的机器人在使用命令回复后对其他人的消息做出反应。您可以使用 message.reference.

@client.command()
async def reply(ctx):
    channel = ctx.channel #get channel where command was used
    msg = await channel.fetch_message(ctx.message.reference.message_id) #fetching message which command replied to
    await msg.add_reaction("") #sending reaction

其工作原理的示例屏幕截图: