@commands.command(aliases=['cfu', 'clear_user'])
async def clear_from_user(self, ctx, amount: typing.Optional[int]=5, *, username):
    'Clear AMOUNT messages from a specific user. Also deletes the message\n        that invoked this command.\n\n        Usage: "clear <amount> <username>"\n\n        Username is the discord username, not server nickname.\n        '
    msgsSearched = 0
    remaining = amount
    (await ctx.message.delete())
    async for message in ctx.channel.history(limit=1000):
        msgsSearched += 1
        if (message.author.name == username):
            (await message.delete())
            remaining -= 1
            if (remaining == 0):
                break
    else:
        (await ctx.send(f'There were less than {amount} messages from {username} in the last {msgsSearched} messages.'))
Clear AMOUNT messages from a specific user. Also deletes the message
that invoked this command.

Usage: "clear <amount> <username>"

Username is the discord username, not server nickname.
@commands.command(aliases=['cfu', 'clear_user'])
async def clear_from_user(self, ctx, amount: typing.Optional[int]=5, *, username):
    'Clear AMOUNT messages from a specific user. Also deletes the message\n        that invoked this command.\n\n        Usage: "clear <amount> <username>"\n\n        Username is the discord username, not server nickname.\n        '
    msgsSearched = 0
    remaining = amount
    (await ctx.message.delete())
    async for message in ctx.channel.history(limit=1000):
        msgsSearched += 1
        if (message.author.name == username):
            (await message.delete())
            remaining -= 1
            if (remaining == 0):
                break
    else:
        (await ctx.send(f'There were less than {amount} messages from {username} in the last {msgsSearched} messages.'))