title: discord.py - How to purge messages from a mentioned user?
body: <p>I have found this <a href="https://stackoverflow.com/questions/62224912/is-there-a-way-to-do-a-check-for-pinned-messages-and-only-purge-a-certain-membe">question</a> but for some reason it doesn't when I mention a user. It doesn't show any errors on the terminal when I execute the command. The code looks like this from the question:</p>
  <pre class="lang-py prettyprint-override"><code>@commands.command()
  @commands.has_permissions(manage_messages=True)
  async def purge(self, ctx, num: int, user: discord.Member = None):
      if user:
          check_func = lambda msg: msg.author == user and not msg.pinned
      else:
          check_func = lambda msg: not msg.pinned
      await ctx.message.delete()
      await ctx.channel.purge(limit=num, check=check_func)
      await ctx.send(f'{num} messages deleted.', delete_after=5)
  </code></pre>
  <p>It works with only a number of messages like <code>q!purge 5</code> but not with <code>q!purge 5 @SomeUser#1234</code>.</p>