简体   繁体   English

如何回复嵌入 discord.py 命令扩展

[英]How to reply an embed discord.py command extension

I cannot reply an embed message (code below)我无法回复嵌入消息(代码如下)

await ctx.send(embed=embed)

Error message:错误信息:

In message_reference: Unknown message

Purge command if needed如果需要,清除命令

@bot.command(name='Purge', help= 'Deletes a certain amount of messages')
async def purge(ctx, limit: int, *, Reason=None):

  embed = discord.Embed(title="Purged", description=f"{limit} messages was purged.", colour=discord.Colour.green())
  embed.add_field(name="Reason", value=Reason, inline=False)
  await ctx.channel.purge(limit=limit)
  await ctx.send(embed=embed)

So my question is how to reply an embed?所以我的问题是如何回复嵌入? It seemed like you can't send an embed using ctx.reply() method似乎您无法使用 ctx.reply() 方法发送嵌入

Don't delete the message不要删除消息

The problem is that you are deleting the message and then trying to reply to it, which can't happen, therefore the Unknown message error since the message is already deleted and does not exist anymore问题是您正在删除该消息,然后尝试回复它,这不可能发生,因此出现未知消息错误,因为该消息已被删除并且不再存在

What to do该怎么办

I suggest not replying here at all since I think everyone will just delete that message after using the purge command.我建议根本不要在这里回复,因为我认为每个人都会在使用 purge 命令后删除该消息。 But if for some reason you want to reply, I don't think there is a efficient way of doing that in a purge command.但是,如果出于某种原因您想回复,我认为在清除命令中没有一种有效的方法可以做到这一点。 You can just not reply and just send the embed in a normal message and that would work fine您可以不回复,只需将嵌入发送到普通消息中,这样就可以了

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM