Discord.py bot is not detecting user input

So I made a command where you need to guess who the impostor is. But the bot doesn't seem to pick the user's response i.e. their choice for who is the impostor..

The code -

    async def impostor(self, ctx):
        def check(message):
            return message.author == ctx.author and message.channel == ctx.channel

        impostor_list = ['red', 'yellow', 'white', 'purple', 'pink', 'orange', 'lime', 'green', 'cyan', 'brown', 'blue']
        impostor = random.choice(impostor_list)

        embed = discord.Embed(title="Guess the impostor!", description="Who is sussy? Write their color in chat within 20s to continue!", color = discord.Color.random())
        embed.add_field(name="The people are:", value="```red, yellow, white, purple, pink, orange, lime, green, cyan, blue, brown```")

        send_em = await ctx.send(embed=embed)
            user_response = await self.client.wait_for("message", timeout=20, check=check)
        except asyncio.TimeoutError:
            return await ctx.send("You took too long to answer.")
            if user_response.content == impostor:
                correct_em = discord.Embed(title=f"{user_response} was ejected.", description=f"{user_response} was the Impostor. Well done!", color = discord.Color.random())

                return await ctx.send(embed=correct_em)
                wrong_em = discord.Embed(title=f"{user_response} was ejected.", description=f"{user_response} was not the Impostor.\nYou lose! {impostor} was the Impostor.")
                return await ctx.send(embed=wrong_em)

If you have a solution please answer. Thanks in advance.

Read more here: https://stackoverflow.com/questions/68457638/discord-py-bot-is-not-detecting-user-input

Content Attribution

This content was originally published by TigerNinja at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: