【发布时间】:2021-01-27 09:11:12
【问题描述】:
嘿,所以我试图在 discord.py 重写版本中创建一个命令,就像 >purgemessage 5 会清除发送该消息的用户的 5 条消息,但由于某种原因,它不起作用。我在回复中使用它,所以它不会显示错误;-;但这是我迄今为止所做的努力让它发挥作用!
# purges author's messages
@commands.command(name='purgemessage', aliases=['pm'])
@commands.cooldown(1, 300)
@commands.has_any_role(OwnerRole, GuildMasterRole, AdminRole, ExclusiveMemberRole)
async def purgemessage(self, ctx, amount:int, *, arg:str=None):
msg = []
channel = ctx.message.channel.history(limit=None)
async for message in channel:
if message.author == ctx.message.author:
msg.append(message)
await ctx.message.channel.delete_messages(msg)
await asyncio.sleep(.5)
botMessage = await ctx.send(f'**{amount}** messages were successfully deleted!')
await asyncio.sleep(.5)
await botMessage.delete()
【问题讨论】:
标签: python discord discord.py discord.py-rewrite purge