bot executes next command without waiting for message

Hello I have been trying to create a application bot for my server the bot sends you a questions then the person answers then its noted down ect but my problem is that sometimes the next question would send without waiting for the answer to the previous question. this only happens most of the time. try i might i have not been able to fix the problem. I’m pretty new to python and at the end of my wits. my code for reference:

import os       
from discord.ext import commands    
from discord.utils import get 
BOT_PREFIX = ("!")
client = commands.Bot(command_prefix=BOT_PREFIX)    
a_list = []   
@client.event
async def on_ready():
    print ("------------------------------------")
    print ("Bot Name: " + client.user.name)
    print ("------------------------------------")        
submit_wait = False
a_list = []
b_list = []
c_list = []
d_list = []      
@client.command(aliases=['application'])
async def app(ctx):
    a_list = []
    b_list = []
    c_list = []
    d_list = []
    submit_wait = False    
    submit_channel = client.get_channel(806404345830047744)
    channel = await ctx.author.create_dm()
    await channel.send("starting applaction!")
    await ctx.send(ctx.author.mention + "check your dms!")
    time.sleep(2)    
    def check(m):
        return m.content is not None and m.channel == channel        
    await channel.send("Do you have any prior milli sim experiance?")
    msg = await client.wait_for('message', check=check)
    a_list.append(msg.content)        
    await channel.send("What time zone are you in?")        
    msg2 = await client.wait_for('message', check=check)
    b_list.append(msg2.content)        
    await channel.send("If a officer ordered you to break the genva convention would you do it?")        
    msg3 = await client.wait_for('message', check=check)
    c_list.append(msg3.content)        
    await channel.send("Is there any particular dvision you want to be in?")    
    msg4 = await client.wait_for('message', check=check)
    d_list.append(msg4.content)       
    await channel.send('thank you for applying! a officer will do your application as soon as they can - respound with "submit" to submit your application')
    msg = await client.wait_for('message', check=check)
    if "submit" in msg.content.lower():
      submit_wait = False
      answers = "\n".join(f'{a}. {b}' for a, b in enumerate(a_list, 1))
      answer = "\n".join(f'{a}. {b}' for a, b in enumerate(b_list, 2))
      answerr = "\n".join(f'{a}. {b}' for a, b in enumerate(c_list, 3))
      answerss = "\n".join(f'{a}. {b}' for a, b in enumerate(d_list, 4))                
      submit_msg = f'Application from {msg.author} \nThe answers are:\n{answers}'
      submit_msg2 = f'{answer}'
      submit_msg3 = f'{answerr}'
      submit_msg4 = f'{answerss}'
      await submit_channel.send(submit_msg)
      await submit_channel.send(submit_msg2)   
      await submit_channel.send(submit_msg3)
      await submit_channel.send(submit_msg4)   
client.run(os.getenv('TOKEN'))


Read more here: https://stackoverflow.com/questions/66267069/bot-executes-next-command-without-waiting-for-message

Content Attribution

This content was originally published by alex cole 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: