A typeracer in discord.py

  discord.py, discord.py-rewrite, python

What I’m doing: I’m trying to make a typeracer in discord.py, but first I’m trying to wrap my head around using def check and def inner_check.

Problem: As seen in the image below, when I type the correct sentence it still tells me that I’m wrong. There is no error as far as I have checked. I used the code from this link here, which helped with the author input in case that helps.

It's not working as I hoped it would

Code:

@client.command()
async def tr(ctx):
    starttime = time.time()
    C = "Just a nice little test"
    await ctx.send(f"Type: {C}")
    a = 1
    def check(author):
        def inner_check(message):
            return message.author == author and message.content == C
        return inner_check
    while a == 1:
        msg = await client.wait_for('message', check=check(ctx.author))
        if msg == True:
            a = a - 1
        else:
            await ctx.send("wrong")
    fintime = time.time()
    total = fintime - starttime
    await ctx.send(round(total,2),"seconds")

Source: Python Questions

LEAVE A COMMENT