Hey so I was trying to make a command in discord.py rewrite version was doing something like >purgemessage 5 would purge 5 messages of the user who sent that message but for some reason, it won't work. I am using this in a reply so it won't show the error;-; but here is what I have done so far to try to make it work!
# 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()