Skip to content

Commit 54b43c6

Browse files
committed
Send ack on form submission so Discord doesn't drop the interaction
Co-authored-by: @nekeal
1 parent eb6be67 commit 54b43c6

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

  • src/europython_discord/registration

src/europython_discord/registration/cog.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ async def on_submit(self, interaction: discord.Interaction) -> None:
5555
order = self.order_field.value
5656

5757
_logger.info(f"Registration attempt: {order=}, {name=}")
58+
59+
# send initial reaction so Discord doesn't drop the interaction after 3 seconds
60+
interaction.response.defer(ephemeral=True, thinking=True)
5861
tickets = self.pretix_connector.get_tickets(order=order, name=name)
5962

6063
if not tickets:
@@ -127,13 +130,13 @@ async def on_error(self, interaction: Interaction, error: Exception) -> None:
127130

128131
@staticmethod
129132
async def log_registration_to_user(interaction: Interaction, *, name: str) -> None:
130-
await interaction.response.send_message(
131-
f"Thank you {name}, you are now registered!\n\n"
132-
f"Also, your nickname was changed to the name you used to register your ticket. "
133-
f"This is also the name that would be on your conference badge, which means that "
134-
f"your nickname can be your 'virtual conference badge'.",
135-
ephemeral=True,
136-
delete_after=None,
133+
await interaction.edit_original_response(
134+
content=(
135+
f"Thank you {name}, you are now registered!\n\n"
136+
f"Also, your nickname was changed to the name you used to register your ticket. "
137+
f"This is also the name that would be on your conference badge, which means that "
138+
f"your nickname can be your 'virtual conference badge'."
139+
)
137140
)
138141

139142
async def log_registration_to_channel(
@@ -152,10 +155,8 @@ async def log_error_to_user(self, interaction: Interaction, message: str) -> Non
152155
reg_help_channel = discord_get(
153156
interaction.guild.channels, name=self.config.registration_help_channel_name
154157
)
155-
await interaction.response.send_message(
156-
f"{message} If you need help, please contact us in {reg_help_channel.mention}.",
157-
ephemeral=True,
158-
delete_after=None,
158+
await interaction.edit_original_response(
159+
content=f"{message} If you need help, please contact us in {reg_help_channel.mention}.",
159160
)
160161

161162
async def log_error_to_channel(self, interaction: Interaction, message: str) -> None:

0 commit comments

Comments
 (0)