def on_message_delete(self, msg: discord.Message):
# don't handle message deletion elsewhere
if not isinstance(msg.channel, discord.TextChannel):
return
# do not process bulk message deletes, or message censors (the censor cog does that already)
# TODO: do this but cleanly, maybe paste website?
if await self.bulk_deletes.check_batch(msg.id) or await self.censored_messages.check(message_id=msg.id):
return
# if this channel isn't publicly visible or deletes shouldn't be tracked, bail
if (not await is_publicly_visible(self.bot, msg.channel) or
await self.bot.config_is_set(msg.guild, 'modlog_notrack_deletes')):
return
# if the author was a bot and we aren't configured to allow bots, return
if msg.author.bot and not await self.bot.config_is_set(msg.guild, 'modlog_filter_allow_bot'):
return
# format attachment list
attachments = 'no attachments' if not msg.attachments else f'{len(msg.attachments)} attachment(s): ' + \
', '.join(f'{a.filename}, {filesize(a.size)}' for a in msg.attachments)
content = utils.prevent_codeblock_breakout(utils.truncate(msg.content, 1500))
fmt = (f'\U0001f6ae Message by {describe(msg.author)} deleted in {msg.channel.mention}: ```\n{content}\n``` '
f'({attachments}, {len(msg.embeds)} embed(s)')
await self.log(msg.guild, fmt)
评论列表
文章目录