How can I get user input in a python discord bot?

You'll be wanting to use Client.wait_for():

@client.command(name="command")
async def _command(ctx):
    global times_used
    await ctx.send(f"y or n")

    # This will make sure that the response will only be registered if the following
    # conditions are met:
    def check(msg):
        return msg.author == ctx.author and msg.channel == ctx.channel and \
        msg.content.lower() in ["y", "n"]

    msg = await client.wait_for("message", check=check)
    if msg.content.lower() == "y":
        await ctx.send("You said yes!")
    else:
        await ctx.send("You said no!")

    times_used = times_used + 1

And with a timeout:

import asyncio # To get the exception

@client.command(...)
async def _command(ctx):
    # code
    try:
        msg = await client.wait_for("message", check=check, timeout=30) # 30 seconds to reply
    except asyncio.TimeoutError:
        await ctx.send("Sorry, you didn't reply in time!")

References:

  • Client.wait_for() - More examples in here
  • Message.author
  • Message.channel
  • Message.content
  • asyncio.TimeoutError