Added Timeout message to application process

main
Anorak_1 2023-08-01 22:42:18 +02:00
parent 9cd5e8efa4
commit 13dab13988
1 changed files with 11 additions and 8 deletions

19
bot.py
View File

@ -197,14 +197,17 @@ class ApplicationStartButtonView(discord.ui.View):
application = {'userId': interaction.user.id} application = {'userId': interaction.user.id}
for i in range(1, max_questions+1): for i in range(1, max_questions+1):
embed = discord.Embed(title=f'Question [{i}/{max_questions}]', description=questions[i]) try:
await user.send(embed=embed) embed = discord.Embed(title=f'Question [{i}/{max_questions}]', description=questions[i])
response = await bot.wait_for('message', check=lambda m: m.author == interaction.user and m.channel == user, timeout=300) await user.send(embed=embed)
if response.content.startswith("cancel"): response = await bot.wait_for('message', check=lambda m: m.author == interaction.user and m.channel == user, timeout=300)
await user.send("Your application has been cancelled") if response.content.startswith("cancel"):
return await user.send("Your application has been cancelled")
else: return
application[f'question{i}'] = response.content else:
application[f'question{i}'] = response.content
except TimeoutError:
user.send(content="As you haven't replied in 300 seconds, your application has been cancelled")
try: try:
with open('applications.json', 'r') as f: with open('applications.json', 'r') as f: