From f46060a58094a2069fc05907ee0b28563da21dd4 Mon Sep 17 00:00:00 2001 From: Matsu Date: Thu, 4 Jun 2026 21:09:39 -0400 Subject: [PATCH] fix(report): defer slash command interaction to prevent timeout Discord requires slash command interactions to be acknowledged within 3 seconds or it shows "This application did not respond." The /report and /emergency commands were doing several async operations (config reads, channel history fetch, log channel message sends) before responding to the interaction, regularly exceeding that window. The fix defers the interaction immediately at the start of do_report, which acknowledges Discord instantly and allows unlimited time to complete the work before sending the followup confirmation. --- .DS_Store | Bin 0 -> 14340 bytes report/report.py | 12 ++++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..da5b77c486cb383cc01e83b3909039670c53ab8d GIT binary patch literal 14340 zcmeI2TWB0r7{|}1o6VY}X^i5vnoa174V1LDTB)|vy7dBHYKtNj%xyQ9HhalsV=7eE zQUu@Pi-K5*4{hm-4+`FB!5h{GDHO!MNqy1>LG;CX!TSHsOwN4Y?3vvSf+(B`GiNjB z|IPP1-<)&ie6y>RO6;lRHY+u#luBc#vbz(9mz2s-$u_E|y=Gg3GYRa=*zvhrsc}_O zvuaG`acsP`KtlFO>}l8(xqYFO&5ll&MyYPsw$Id?ub$t%^8fR{ta}&d-R2_TBH$w6 zBH$w6BCz@h(6bj?y2CHs(M7;Tz(v4BfaZq`b}GG~too&%I&h#RJk`?@UT^q}JV2kz z1f>_0Rln4xu+gR{ebYpcVkCTXoX?OPr5BV{zx2&j!Z%lmz;hzVP!ifZ>@r%e5}seW zqlD=e;P*9VWAb~WXb-ja|o|Gye9<%B&`q_ev$o>x z)^dgmRl~sSd9Sc5q<=k)uG8ae6i13i4n4Do8D$8cOLWI%WUd|uQv(am`TMz-Z#wwe z`Q6P}h0$x?O0>scd9`8=q&K^mO(c8U9vx3p%Q>HVg~gL8LMFRH_}A~W)wS?HN#6C5 zVwnRE-QO`BrzqNzYwNS%YQl>1CQH5j&-ig|$}()n>MUjZbbq-nc*YcTt0r-*pshnF z7g0lR#L>AD9gKE9#&ZSXur{TIEsqUL3^2M$O&EzdjpV4p4f^9E)~;jGytn;+UdR3Kz0vqLwmbs1dg)iU zpM3w5Z5xb}Y7<5hay@Ye`)~b~*Kv0G{{5)G-Z8eE-BvHyH(Vy>wiUlvn^n}P@UC_) z)hal{sZTx)`*OhVUx$;#s|1hIJZr&IMuw|b|2Piee$o>bt18LX@*&vjs5$5Nzx_E7 ztPSg0guSjg3(4;R2y22(7zudy0&>dFF+)o3o-1}0=bd@_owFzLTZ=el$XQ=0`Se`T zq4_EpspIjnRjC5EqbM`d&Yt9tU}UwN>%zCE z-Vfp@6d{XU!TonVd>Ib(_*lU6mR2mtTI9WK`KwmJIo`S`#s|9&A0P25&g1_+2>ok> zo;jc~Yfs7aKo(3E73b7{3qMJ4#UWBBy-c zDkYx>$5_*iB7#MIKP$9`lF{q#vuQZn9XA-Znrm^gdOFFa`*}OK^0==$Q`FCLlCwvkqH?t}Z<_xtkR-t!Y$5c}qUbFMyv=j5xm zmTl2voaOJb6)yjm@o@S767~Jq99>4s<^Ot~2;L+i7trq<I;n}}%%{njpneHc4wKE_TPK5G*kNJ9VUpX1>l`Z?ZqI=8Z+&ZEyLtA2@3 m*#7k&0=oR4{bozA>8!cBTv@pMU#`W1xLNXg8Mps#{{J`In)xgM literal 0 HcmV?d00001 diff --git a/report/report.py b/report/report.py index fae571cc..3f2a769e 100644 --- a/report/report.py +++ b/report/report.py @@ -315,6 +315,10 @@ async def do_report( report_type = "emergency" if emergency else "regular" logger.debug(f"Processing {report_type} report from {message.author.name} ({message.author.id})") + # Acknowledge the interaction immediately to avoid Discord's 3-second timeout + if interaction is not None and not interaction.response.is_done(): + await interaction.response.defer(ephemeral=True) + # Pre-emptively delete the message for privacy reasons if interaction is None: logger.debug("Deleting original report message for privacy") @@ -350,9 +354,9 @@ async def do_report( report_reply = self.make_reporter_reply(channel.guild, channel, report_body, emergency) # Send interaction response if this is a slash command - if interaction is not None and not interaction.response.is_done(): - logger.debug("Sending confirmation via interaction response") - await interaction.response.send_message(embed=report_reply, ephemeral=True) + if interaction is not None: + logger.debug("Sending confirmation via interaction followup") + await interaction.followup.send(embed=report_reply, ephemeral=True) # Else send a DM if DM confirmations are enabled elif await self.config.guild(channel.guild).confirmations(): @@ -409,7 +413,7 @@ async def notify_truncation( f"⚠️ Your report was truncated from {original_length} to {truncated_length} characters " f"due to Discord's limits. The report was still sent successfully." ) - if interaction is not None and not interaction.response.is_done(): + if interaction is not None: await interaction.followup.send(truncation_msg, ephemeral=True) logger.debug("Truncation notification sent via interaction followup message") else: