擅长:python、mysql、java
<p>我在这里改正了一些错误。试着通读不和.py关于<a href="https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.purge_from" rel="nofollow noreferrer">purging</a>消息的文档。在</p>
<pre><code> class ModLog:
def __init__(self, bot):
self.bot = bot
async def on_ready(self):
await self.bot.wait_until_ready()
for server in self.bot.servers:
channel = self.bot.get_channel("channel ID here")
if channel:
self.bot.loop.create_task(self.modlog_purge(channel))
async def modlog_purge(self, channel):
while True:
now = datetime.utcnow()
two_weeks_ago = now - timedelta(days=14)
await self.bot.purge_from(channel, before=two_weeks_ago)
await asyncio.sleep(86400)
def setup(bot):
q = ModLog(bot)
bot.add_cog(q)
</code></pre>