parent
							
								
									458259c252
								
							
						
					
					
						commit
						678e912f13
					
				
							
								
								
									
										9
									
								
								bot.py
								
								
								
								
							
							
						
						
									
										9
									
								
								bot.py
								
								
								
								
							| 
						 | 
					@ -33,6 +33,7 @@ max_questions = len(questions)
 | 
				
			||||||
@bot.event
 | 
					@bot.event
 | 
				
			||||||
async def on_ready():
 | 
					async def on_ready():
 | 
				
			||||||
    bot.add_view(ApplicationButtonsView())
 | 
					    bot.add_view(ApplicationButtonsView())
 | 
				
			||||||
 | 
					    bot.add_view(ApplicationStartButtonView())
 | 
				
			||||||
    print(f"Logged in as {bot.user}")
 | 
					    print(f"Logged in as {bot.user}")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@bot.slash_command(description = "Command used to apply")
 | 
					@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)
 | 
					        await interaction.response.send_message(content="Application started", ephemeral=True)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        user = await interaction.user.create_dm()
 | 
					        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}
 | 
					        application = {'userId': interaction.user.id}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -190,6 +193,10 @@ class ApplicationStartButtonView(discord.ui.View):
 | 
				
			||||||
            embed = discord.Embed(title=f'Question [{i}/{max_questions}]', description=questions[i])
 | 
					            embed = discord.Embed(title=f'Question [{i}/{max_questions}]', description=questions[i])
 | 
				
			||||||
            await user.send(embed=embed)
 | 
					            await user.send(embed=embed)
 | 
				
			||||||
            response = await bot.wait_for('message', check=lambda m: m.author == interaction.user and m.channel == user, timeout=300)
 | 
					            response = await bot.wait_for('message', check=lambda m: m.author == interaction.user and m.channel == user, timeout=300)
 | 
				
			||||||
 | 
					            if response.content.startswith("cancel"):
 | 
				
			||||||
 | 
					                await user.send("Your application has been cancelled")
 | 
				
			||||||
 | 
					                return
 | 
				
			||||||
 | 
					            else:
 | 
				
			||||||
                application[f'question{i}'] = response.content
 | 
					                application[f'question{i}'] = response.content
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue