[英]discord.py :: How do I make on_message_delete ignore a certain user / role via an embed?
I have a log channel set so if a user deletes a message, it gets sent to the channel so my moderators and myself can see deleted messages.我设置了一个日志频道,所以如果用户删除了一条消息,它会被发送到该频道,这样我的版主和我自己就可以看到已删除的消息。
@client.event
async def on_message_delete(message):
if not message.author.bot:
embed = Embed(title = "[❌] A message has been deleted by a user.",
description = f"{message.author.display_name} (`{message.author.id}`) has deleted a message in the {message.channel.mention} channel.",
color = message.author.color,
timestamp = datetime.utcnow())
fields = [("Message:", message.content, False)]
for name, value, inline in fields:
embed.add_field(name=name, value=value, inline=inline)
embed.set_thumbnail(url = message.author.avatar_url)
embed.set_footer(text = "This message was deleted")
channel = client.get_channel(828362680452644904)
await channel.send(embed=embed)
I want to make it so this does not send an embed showcasing what my moderators or myself deleted to avoid clutter.我想这样做,这样就不会发送一个嵌入来展示我的版主或我自己为避免混乱而删除的内容。 Is there a way to do this?
有没有办法做到这一点?
You can just return
if the message meets these conditions:如果消息满足以下条件,您就可以
return
:
# get these values from your guild
MY_ID = 1234
MODERATOR_ROLE_ID = 56678
async def on_message_delete(message):
if message.author.id == MY_ID:
return
author_role_ids = [role.id for role in message.author.roles]
if MODERATOR_ROLE_ID in author_role_ids:
return
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.