我一直在研究一个不和谐的机器人,我能够创建狙击命令,很好地狙击最近删除的消息,但现在我正在尝试对其进行编程,以便能够编辑狙击最近删除的消息编辑的消息
这是我的狙击删除消息代码
async def on_ready(self):
print('Snipe commands are working')
@commands.Cog.listener()
async def on_message_delete(self, message):
global snipe_message_content
global snipe_message_author
global snipe_message_id
global snipe_message_channel
global snipe_message_author_avatar
global a
global b
snipe_message_content = message.content
snipe_message_author = message.author.id
snipe_message_id = message.id
snipe_message_channel = message.channel
snipe_message_author_avatar = message.author.avatar_url
a = message.author.name
b = message.author.discriminator
if (snipe_message_author in botsid):
m == 1
else:
embed = discord.Embed(description=f"?️ **Message sent by** <@!{snipe_message_author}> **deleted in** {message.channel.mention} \n \n {snipe_message_content}")
embed.set_author(name= f" {message.author.name}#{message.author.discriminator}")
channel = self.client.get_channel(795726497922809947)
await channel.send(embed=embed)
答案 0 :(得分:1)
您可以通过在编辑消息之前使用 on_message_edit 和使用 message_before 来简单地实现这一点。下面是一个例子
async def on_message_edit(message_before, message_after):
author = message_before.author
guild = message_before.guild.name
channel = message_before.channel
await channel.send(f"""
Original Message
{message_before.content}
Updated Message
{message_after.content}""")
从这里,你可以复制你上面所做的。