'discord bot can't handle requests from different users

im trying to create a chatbot that has conversations sequentially like this. this works with one user fine but if another user tries to use the bot at the same time it interferes with the first user. I understand I would have to use some sort of asynchronous programming to fix this but I'm not sure how. any help would be appreciated

@client.event
async def on_message(msg):
    if msg.author.bot:
        return

    if msg.content == "hey":
        await msg.channel.send('hi')
        
        response = await client.wait_for('message')  
        


        if response.content =="how are you":
            await response.channel.send('good')
        
client.run(token)


Solution 1:[1]

Explanation

response = await client.wait_for('message') will catch any message sent after the command is executed, regardless of whom it's from.

This can be rectified by adding a check to wait_for, like in the code below.

Code

response = await client.wait_for('message', check=lambda message: message.author == msg.author)

Reference

wait_for

lambda expressions

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1