我有一个不需要的小功能,我的机器人无法识别在首次发送后大约5秒钟后是否删除了一条消息。下面是我用于记录已删除邮件的代码
@commands.Cog.listener()
async def on_message_delete(self, c):
if(c.guild):
if c.guild.name == "Server Name":
if c.author.bot == True:
print(f"{c.created_at} || Bot: {c.author} deleted --- {c.content} --- in #{c.channel}");
else:
print(f"{c.created_at} || User: {c.author} deleted --- {c.content} --- in #{c.channel}");
我知道在文档中有一个名为“ max messages”的值,该值与“ on_message_delete”相关。没有成功,我无法实现它。我正在寻找服务器范围的日志记录,例如,如果有人从5天前删除了一条消息。如果可以的话
答案 0 :(得分:0)
使用以下事件可能会有所帮助,因为它不需要消息存储在缓存中
@commands.Cog.listener()
async def on_raw_message_delete(self, payload):
if payload.guild_id:
guild = self.bot.get_guild(payload.guild_id)
channel = self.bot.get_channel(payload.channel_id)
message = await channel.fetch_message(payload.message_id)
if guild.name == "Server Name":
if message.author.bot: # more pythonic way of checking bools
print(...
else:
print(...
参考:
答案 1 :(得分:0)
[[ "X${DNSMASQ_SUPPLIED_HOSTNAME}" == "X" ]] || VALIDHOST=${DNSMASQ_SUPPLIED_HOSTNAME}
[[ "X${VALIDHOST}" == "X" ]] && export VALIDHOST=${FILEVALIDHOST}
[[ "X${VALIDHOST}" == "X" ]] && VALIDHOST="unknown_`echo $VALIDHOSTMAC|tr -d ':'`"