python-3.x - 大约 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')
解决方案
推荐阅读
- java - Univocity - 如何动态提供日期格式
- python - Python:通过电子邮件字符串解析正则表达式函数并返回元组或如果输入无效则返回 ValueError
- r - 基于正则表达式的列表中的子集数据框
- ms-access - 使用 pyodbc 添加到 MS Access 数据库
- zig - 不能使用二维数组的 .len
- c++ - Eigen - 将向量重塑为矩阵
- r - 从包含单引号和双引号的字符创建字符串?
- c# - 自定义 ListView 中的 BaseAdapter,我如何使其在空视图中更健壮
- mysql - mysql用数据目录创建表:访问被拒绝
- c - 你能解决一个int的单个位吗?