所以我一直在努力解决100条不和谐信息。py purge limit通过将清除分为几组100个,但我遇到了一个问题,当我使用这个命令时,我发现了一个错误。我已经测试过了
节省物
列表中的消息
错误
Ignoring exception in command purge
Traceback (most recent call last):
File "C:\Users\info\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\ext\commands\core.py", line 50, in wrapped
ret = yield from coro(*args, **kwargs)
File "C:\Users\info\OneDrive\Desktop\Azogthe Rewrite\moderation.py", line 312, in purge
await self.bot.delete_messages(mgs1)
File "C:\Users\info\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\client.py", line 1301, in delete_messages
yield from self.http.delete_messages(channel.id, message_ids, guild_id)
File "C:\Users\info\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\http.py", line 200, in request
raise HTTPException(r, data)
discord.errors.HTTPException: BAD REQUEST (status code: 400)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\info\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\ext\commands\bot.py", line 846, in process_commands
yield from command.invoke(ctx)
File "C:\Users\info\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\ext\commands\core.py", line 374, in invoke
yield from injected(*ctx.args, **ctx.kwargs)
File "C:\Users\info\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\ext\commands\core.py", line 54, in wrapped
raise CommandInvokeError(e) from e
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: BAD REQUEST (status code: 400)
密码
@commands.command(pass_context=True, no_pm=True)
async def purge(self, ctx, amount = None, channel:discord.Channel = None):
mgs1 = []
mgs2 = []
mgs3 = []
mgs4 = []
mgs5 = []
if channel == None:
channel = ctx.message.channel
amount = int(amount)
if amount > 1:
async for x in self.bot.logs_from((channel), limit = int(amount+1)):
while len(mgs1) < 100:
mgs1.append(x)
while len(mgs1) == 100 and len(mgs2) < 100:
mgs2.append(x)
while len(mgs2) == 100 and len(mgs3) < 100:
mgs3.append(x)
while len(mgs3) == 100 and len(mgs4) < 100:
mgs4.append(x)
while len(mgs4) == 100 and len(mgs5) < 100:
mgs5.append(x)
print(mgs1, mgs2, mgs3, mgs4, mgs5)
await self.bot.delete_messages(mgs1)
await self.bot.delete_messages(mgs2)
await self.bot.delete_messages(mgs3)
await self.bot.delete_messages(mgs4)
await self.bot.delete_messages(mgs5)