简体   繁体   中英

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

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. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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