title: Discord Python Bot: Clear Command If statements
body: <p>I am currently tying to make a discord bot in python. It has been about 1 week since I started learning and I thought I would give this a go. I am trying to make a clear function to have it clear the chat. I want to make the bot say "please enter a valid number". If you type anything else other than an <code>int</code> ex. some char.</p>
  
  <p>For example when I put ".clear t" it wont do anything and it gets angry in the terminal. When I put a valid argument such as ".clear 3" it will throw up the "please enter a valid number." after clearing all of it.</p>
  
  <p>I tried different variations of the if statement including placement. Can't figure it out. I have a feeling it be something about where to place the if statement. Thank you for taking the time to read. </p>
  
  <pre><code>@client.command(pass_context = True)
  async def clear(ctx, number = 5):
       number = int(number) 
       counter = 0
       channel = ctx.message.channel
       async for x in client.logs_from(ctx.message.channel, limit = number):
           if counter &lt; number:
               await client.delete_message(x)
               counter += 1
               await asyncio.sleep(0.5) 
       if number != int():
               await client.send_message(channel, "Please enter a valid number.")
  </code></pre>