首页 > 解决方案 > 大约 1234 次编辑后,edit_message 协程上的 ClientResponseError

问题描述

我已经设置了一个机器人来删除成千上万条消息,大约有 20,000 条消息,我的代码有效并且正在删除消息,我还有一条消息不断被编辑,告诉我总共删除了多少条消息,这也有效,但过了一会儿我从该行收到了一个 ClientResponseError 异常,它停止了我的消息删除循环,为什么会发生这种情况?我可以只使用 atry except然后pass这样我的循环就不会停止吗?我不确定该异常是什么,文档上没有任何内容

代码:

counter = 0
begin, end = around_month(month, year)
tmsg = await Client.send_message(ctx.message.channel, 'Progress: 0/' + str(number))
estimate = number * 1.5
estimate = estimate / 60
estimate = estimate / 60
estimate = round(estimate, 2)
await Client.send_message(ctx.message.channel, 'Estimated time: ' + str(estimate) + 'hours')
async for x in Client.logs_from(channelid, limit = number, after=begin, before=end):
    counter += 1
    await Client.edit_message(tmsg, 'Progress: ' + str(counter) + '/' + str(number))
    await Client.delete_message(x)
    await asyncio.sleep(1.5)
await Client.send_message(ctx.message.channel, 'Operation completed! ' + 'Cleared: ' + str(counter) + ' items')

标签: python-3.xdiscord.py

解决方案


推荐阅读