From 9cd5e8efa400c576a663947e2fb7cd8b8c5196be Mon Sep 17 00:00:00 2001 From: Anorak_1 Date: Tue, 1 Aug 2023 22:35:23 +0200 Subject: [PATCH] Implemented checking for dm privacy settings --- bot.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bot.py b/bot.py index d3c01b8..2059a0b 100644 --- a/bot.py +++ b/bot.py @@ -185,7 +185,14 @@ class ApplicationStartButtonView(discord.ui.View): user = await interaction.user.create_dm() 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) + + try: + await user.send(embed=embedd) + except discord.Forbidden: + interaction.response.send_message(content="Can't start application. Please allow direct messages from server members in your privacy settings.", ephemeral=True) + return + + await interaction.response.send_message(content="Application started", ephemeral=True) application = {'userId': interaction.user.id}