parent
458259c252
commit
678e912f13
11
bot.py
11
bot.py
|
@ -33,6 +33,7 @@ max_questions = len(questions)
|
|||
@bot.event
|
||||
async def on_ready():
|
||||
bot.add_view(ApplicationButtonsView())
|
||||
bot.add_view(ApplicationStartButtonView())
|
||||
print(f"Logged in as {bot.user}")
|
||||
|
||||
@bot.slash_command(description = "Command used to apply")
|
||||
|
@ -182,7 +183,9 @@ class ApplicationStartButtonView(discord.ui.View):
|
|||
await interaction.response.send_message(content="Application started", ephemeral=True)
|
||||
|
||||
user = await interaction.user.create_dm()
|
||||
await user.send("Hey! Your application has started. You have 300 seconds to complete it.")
|
||||
embedd = discord.Embed(title=f'CreaTopia Application', description="Hey! Your application has started. You have 300 seconds to complete it.")
|
||||
embedd.add_field(value=f'You can cancel the application by answering "cancel" to any of the questions', name="", inline=False)
|
||||
await user.send(embed=embedd)
|
||||
|
||||
application = {'userId': interaction.user.id}
|
||||
|
||||
|
@ -190,7 +193,11 @@ class ApplicationStartButtonView(discord.ui.View):
|
|||
embed = discord.Embed(title=f'Question [{i}/{max_questions}]', description=questions[i])
|
||||
await user.send(embed=embed)
|
||||
response = await bot.wait_for('message', check=lambda m: m.author == interaction.user and m.channel == user, timeout=300)
|
||||
application[f'question{i}'] = response.content
|
||||
if response.content.startswith("cancel"):
|
||||
await user.send("Your application has been cancelled")
|
||||
return
|
||||
else:
|
||||
application[f'question{i}'] = response.content
|
||||
|
||||
try:
|
||||
with open('applications.json', 'r') as f:
|
||||
|
|
Loading…
Reference in New Issue