@@ -10,8 +10,8 @@ use crate::utils::thread::send_to_thread::send_to_thread;
1010use crate :: utils:: thread:: user_recap:: get_user_recap;
1111use crate :: utils:: time:: get_member_join_date:: get_member_join_date_for_user;
1212use serenity:: all:: {
13- ActionRowComponent , Channel , ChannelId , ComponentInteraction , Context , CreateChannel , GuildId ,
14- Message , ModalInteraction , UserId ,
13+ ActionRowComponent , Channel , ChannelId , ComponentInteraction , Context , CreateChannel ,
14+ CreateInteractionResponseFollowup , GuildId , Message , ModalInteraction , UserId ,
1515} ;
1616use serenity:: builder:: { CreateInteractionResponse , EditChannel , EditMessage } ;
1717use std:: collections:: HashMap ;
@@ -175,28 +175,17 @@ pub async fn handle_thread_modal_interaction(
175175 let parts = match parse_thread_interaction ( & interaction. data . custom_id ) {
176176 Some ( parts) => parts,
177177 None => {
178- let response = CreateInteractionResponse :: Message (
179- MessageBuilder :: system_message ( & ctx, & config)
180- . translated_content (
181- "feature.not_implemented" ,
182- None ,
183- Some ( interaction. user . id ) ,
184- interaction. guild_id . map ( |g| g. get ( ) ) ,
185- )
186- . await
187- . to_channel ( interaction. channel_id )
188- . build_interaction_message ( )
189- . await
190- . ephemeral ( true ) ,
191- ) ;
192- let _ = interaction. create_response ( & ctx. http , response) . await ;
193178 return Ok ( ( ) ) ;
194179 }
195180 } ;
196181
197182 let key = interaction. channel_id . get ( ) ;
198183 let lock = get_thread_lock ( config, key) ;
199184
185+ interaction
186+ . create_response ( & ctx. http , CreateInteractionResponse :: Acknowledge )
187+ . await ?;
188+
200189 let guard = match lock. try_lock ( ) {
201190 Ok ( guard) => guard,
202191 Err ( _) => {
@@ -240,9 +229,9 @@ pub async fn handle_thread_modal_interaction(
240229 Err ( _) => {
241230 eprintln ! ( "Invalid user ID provided in modal interaction: {}" , id) ;
242231 let _ = interaction
243- . create_response (
232+ . create_followup (
244233 & ctx. http ,
245- CreateInteractionResponse :: Message (
234+ CreateInteractionResponseFollowup :: from (
246235 MessageBuilder :: system_message ( ctx, config)
247236 . translated_content (
248237 "thread.modal_invalid_user_id" ,
@@ -252,7 +241,7 @@ pub async fn handle_thread_modal_interaction(
252241 )
253242 . await
254243 . to_channel ( interaction. channel_id )
255- . build_interaction_message ( )
244+ . build_interaction_message_followup ( )
256245 . await
257246 . ephemeral ( true ) ,
258247 ) ,
@@ -271,9 +260,9 @@ pub async fn handle_thread_modal_interaction(
271260 Err ( _) => {
272261 eprintln ! ( "Failed to fetch user by ID: {}" , user_id) ;
273262 let _ = interaction
274- . create_response (
263+ . create_followup (
275264 & ctx. http ,
276- CreateInteractionResponse :: Message (
265+ CreateInteractionResponseFollowup :: from (
277266 MessageBuilder :: system_message ( ctx, config)
278267 . translated_content (
279268 "thread.modal_user_not_found" ,
@@ -283,7 +272,7 @@ pub async fn handle_thread_modal_interaction(
283272 )
284273 . await
285274 . to_channel ( interaction. channel_id )
286- . build_interaction_message ( )
275+ . build_interaction_message_followup ( )
287276 . await
288277 . ephemeral ( true ) ,
289278 ) ,
@@ -299,14 +288,14 @@ pub async fn handle_thread_modal_interaction(
299288 user_id
300289 ) ;
301290 let _ = interaction
302- . create_response (
291+ . create_followup (
303292 & ctx. http ,
304- CreateInteractionResponse :: Message (
293+ CreateInteractionResponseFollowup :: from (
305294 MessageBuilder :: system_message ( ctx, config)
306295 . translated_content ( "thread.modal_bot_user" , None , None , None )
307296 . await
308297 . to_channel ( interaction. channel_id )
309- . build_interaction_message ( )
298+ . build_interaction_message_followup ( )
310299 . await
311300 . ephemeral ( true ) ,
312301 ) ,
@@ -330,9 +319,9 @@ pub async fn handle_thread_modal_interaction(
330319 format ! ( "<#{}>" , existing_channel_str) ,
331320 ) ;
332321 let _ = interaction
333- . create_response (
322+ . create_followup (
334323 & ctx. http ,
335- CreateInteractionResponse :: Message (
324+ CreateInteractionResponseFollowup :: from (
336325 MessageBuilder :: system_message ( ctx, config)
337326 . translated_content (
338327 "thread.already_exists" ,
@@ -342,7 +331,7 @@ pub async fn handle_thread_modal_interaction(
342331 )
343332 . await
344333 . to_channel ( interaction. channel_id )
345- . build_interaction_message ( )
334+ . build_interaction_message_followup ( )
346335 . await
347336 . ephemeral ( true ) ,
348337 ) ,
@@ -356,9 +345,9 @@ pub async fn handle_thread_modal_interaction(
356345 Ok ( Channel :: Guild ( gc) ) => gc,
357346 _ => {
358347 let _ = interaction
359- . create_response (
348+ . create_followup (
360349 & ctx. http ,
361- CreateInteractionResponse :: Message (
350+ CreateInteractionResponseFollowup :: from (
362351 MessageBuilder :: system_message ( ctx, config)
363352 . translated_content (
364353 "thread.not_a_thread_channel" ,
@@ -368,7 +357,7 @@ pub async fn handle_thread_modal_interaction(
368357 )
369358 . await
370359 . to_channel ( interaction. channel_id )
371- . build_interaction_message ( )
360+ . build_interaction_message_followup ( )
372361 . await
373362 . ephemeral ( true ) ,
374363 ) ,
@@ -382,9 +371,9 @@ pub async fn handle_thread_modal_interaction(
382371 if let Some ( parent_id) = guild_channel. parent_id {
383372 if parent_id. get ( ) != config. thread . inbox_category_id {
384373 let _ = interaction
385- . create_response (
374+ . create_followup (
386375 & ctx. http ,
387- CreateInteractionResponse :: Message (
376+ CreateInteractionResponseFollowup :: from (
388377 MessageBuilder :: system_message ( ctx, config)
389378 . translated_content (
390379 "thread.not_a_thread_channel" ,
@@ -394,7 +383,7 @@ pub async fn handle_thread_modal_interaction(
394383 )
395384 . await
396385 . to_channel ( interaction. channel_id )
397- . build_interaction_message ( )
386+ . build_interaction_message_followup ( )
398387 . await
399388 . ephemeral ( true ) ,
400389 ) ,
@@ -405,14 +394,14 @@ pub async fn handle_thread_modal_interaction(
405394 }
406395 } else {
407396 let _ = interaction
408- . create_response (
397+ . create_followup (
409398 & ctx. http ,
410- CreateInteractionResponse :: Message (
399+ CreateInteractionResponseFollowup :: from (
411400 MessageBuilder :: system_message ( ctx, config)
412401 . translated_content ( "thread.not_a_thread_channel" , None , None , None )
413402 . await
414403 . to_channel ( interaction. channel_id )
415- . build_interaction_message ( )
404+ . build_interaction_message_followup ( )
416405 . await
417406 . ephemeral ( true ) ,
418407 ) ,
@@ -429,14 +418,14 @@ pub async fn handle_thread_modal_interaction(
429418 {
430419 eprintln ! ( "Failed to create thread record: {}" , e) ;
431420 let _ = interaction
432- . create_response (
421+ . create_followup (
433422 & ctx. http ,
434- CreateInteractionResponse :: Message (
423+ CreateInteractionResponseFollowup :: from (
435424 MessageBuilder :: system_message ( ctx, config)
436425 . translated_content ( "thread.creation_failed" , None , None , None )
437426 . await
438427 . to_channel ( interaction. channel_id )
439- . build_interaction_message ( )
428+ . build_interaction_message_followup ( )
440429 . await
441430 . ephemeral ( true ) ,
442431 ) ,
@@ -474,14 +463,14 @@ pub async fn handle_thread_modal_interaction(
474463 format ! ( "<#{}>" , interaction. channel_id) ,
475464 ) ;
476465 let _ = interaction
477- . create_response (
466+ . create_followup (
478467 & ctx. http ,
479- CreateInteractionResponse :: Message (
468+ CreateInteractionResponseFollowup :: from (
480469 MessageBuilder :: system_message ( ctx, config)
481470 . translated_content ( "thread.created" , Some ( & params) , None , None )
482471 . await
483472 . to_channel ( interaction. channel_id )
484- . build_interaction_message ( )
473+ . build_interaction_message_followup ( )
485474 . await
486475 . ephemeral ( true ) ,
487476 ) ,
@@ -500,14 +489,14 @@ pub async fn handle_thread_modal_interaction(
500489 _ => {
501490 eprintln ! ( "Unknown thread modal interaction action: {}" , parts) ;
502491 let _ = interaction
503- . create_response (
492+ . create_followup (
504493 & ctx. http ,
505- CreateInteractionResponse :: Message (
494+ CreateInteractionResponseFollowup :: from (
506495 MessageBuilder :: system_message ( ctx, config)
507496 . translated_content ( "thread.unknown_action" , None , None , None )
508497 . await
509498 . to_channel ( interaction. channel_id )
510- . build_interaction_message ( )
499+ . build_interaction_message_followup ( )
511500 . await ,
512501 ) ,
513502 )
@@ -536,14 +525,14 @@ pub async fn handle_thread_component_interaction(
536525 Ok ( guard) => guard,
537526 Err ( _) => {
538527 let _ = interaction
539- . create_response (
528+ . create_followup (
540529 & ctx. http ,
541- CreateInteractionResponse :: Message (
530+ CreateInteractionResponseFollowup :: from (
542531 MessageBuilder :: system_message ( ctx, config)
543532 . translated_content ( "thread.action_in_progress" , None , None , None )
544533 . await
545534 . to_channel ( interaction. channel_id )
546- . build_interaction_message ( )
535+ . build_interaction_message_followup ( )
547536 . await
548537 . ephemeral ( true ) ,
549538 ) ,
@@ -563,14 +552,14 @@ pub async fn handle_thread_component_interaction(
563552 params. insert ( "user" . to_string ( ) , format ! ( "<@{}>" , interaction. user. id) ) ;
564553
565554 let _ = interaction
566- . create_response (
555+ . create_followup (
567556 & ctx. http ,
568- CreateInteractionResponse :: Message (
557+ CreateInteractionResponseFollowup :: from (
569558 MessageBuilder :: system_message ( ctx, config)
570559 . translated_content ( "thread.thread_closing" , Some ( & params) , None , None )
571560 . await
572561 . to_channel ( interaction. channel_id )
573- . build_interaction_message ( )
562+ . build_interaction_message_followup ( )
574563 . await ,
575564 ) ,
576565 )
@@ -582,14 +571,14 @@ pub async fn handle_thread_component_interaction(
582571 }
583572 "keep" => {
584573 let _ = interaction
585- . create_response (
574+ . create_followup (
586575 & ctx. http ,
587- CreateInteractionResponse :: Message (
576+ CreateInteractionResponseFollowup :: from (
588577 MessageBuilder :: system_message ( ctx, config)
589578 . translated_content ( "thread.will_remain_open" , None , None , None )
590579 . await
591580 . to_channel ( interaction. channel_id )
592- . build_interaction_message ( )
581+ . build_interaction_message_followup ( )
593582 . await ,
594583 ) ,
595584 )
@@ -630,14 +619,14 @@ pub async fn handle_thread_component_interaction(
630619 _ => {
631620 eprintln ! ( "Unknown thread component interaction action: {}" , parts) ;
632621 let _ = interaction
633- . create_response (
622+ . create_followup (
634623 & ctx. http ,
635- CreateInteractionResponse :: Message (
624+ CreateInteractionResponseFollowup :: from (
636625 MessageBuilder :: system_message ( ctx, config)
637626 . translated_content ( "thread.unknown_action" , None , None , None )
638627 . await
639628 . to_channel ( interaction. channel_id )
640- . build_interaction_message ( )
629+ . build_interaction_message_followup ( )
641630 . await ,
642631 ) ,
643632 )
0 commit comments