I have a purge command already that works, but I wanted to try to implement a function that is optional - so you can delete a certain member's messages too. It doesn't work with other member's except for myself at the moment and when member=me, it only purges 1 message from me too. What am I doing wrong?
@commands.has_permissions(manage_messages=True)
async def purge(self, ctx, amount: int, member:discord.Member=None):
if member!=None:
msg=[]
async for m in ctx.channel.history():
if len(msg) == amount:
break
if m.author.id == member.id:
msg.append(m)
await ctx.channel.delete_messages(msg)
await ctx.respond(f"Messages from {member} has been purged")
return
await ctx.respond("Purging messages")
amount += 1
await ctx.channel.purge(limit=amount)```