|
| 1 | +use crate::modules::update_thread_status_ui; |
1 | 2 | use crate::prelude::commands::*; |
2 | 3 | use crate::prelude::config::*; |
3 | 4 | use crate::prelude::db::*; |
@@ -84,28 +85,40 @@ impl RegistrableCommand for TakeCommand { |
84 | 85 | return Err(ModmailError::Command(CommandError::TicketAlreadyTaken)); |
85 | 86 | } |
86 | 87 |
|
87 | | - tokio::spawn(async move { |
88 | | - let _ = rename_channel_with_timeout( |
89 | | - &ctx, |
90 | | - &config, |
91 | | - thread_id, |
92 | | - format!("🔵-{}", command.user.name.clone()), |
93 | | - None, |
94 | | - Some(&command), |
95 | | - ) |
96 | | - .await; |
97 | | - |
98 | | - let mut params = std::collections::HashMap::new(); |
99 | | - params.insert("staff".to_string(), format!("<@{}>", command.user.id)); |
100 | | - |
101 | | - let response = MessageBuilder::system_message(&ctx, &config) |
102 | | - .translated_content("take.confirmation", Some(¶ms), None, None) |
103 | | - .await |
104 | | - .to_channel(command.channel_id) |
105 | | - .build_interaction_message_followup() |
106 | | - .await; |
107 | | - |
108 | | - let _ = command.create_followup(ctx.clone(), response).await; |
| 88 | + tokio::spawn({ |
| 89 | + let config = config.clone(); |
| 90 | + let db_pool = db_pool.clone(); |
| 91 | + |
| 92 | + async move { |
| 93 | + let mut ticket_status = match get_thread_status(&thread.id, &db_pool).await |
| 94 | + { |
| 95 | + Some(status) => status, |
| 96 | + None => { |
| 97 | + return; |
| 98 | + } |
| 99 | + }; |
| 100 | + ticket_status.taken_by = Some(command.user.id.to_string()); |
| 101 | + let _ = update_thread_status_db(&thread.id, &ticket_status, &db_pool).await; |
| 102 | + |
| 103 | + tokio::spawn({ |
| 104 | + let ctx = ctx.clone(); |
| 105 | + async move { |
| 106 | + let _ = update_thread_status_ui(&ctx, &ticket_status).await; |
| 107 | + } |
| 108 | + }); |
| 109 | + |
| 110 | + let mut params = std::collections::HashMap::new(); |
| 111 | + params.insert("staff".to_string(), format!("<@{}>", command.user.id)); |
| 112 | + |
| 113 | + let response = MessageBuilder::system_message(&ctx, &config) |
| 114 | + .translated_content("take.confirmation", Some(¶ms), None, None) |
| 115 | + .await |
| 116 | + .to_channel(command.channel_id) |
| 117 | + .build_interaction_message_followup() |
| 118 | + .await; |
| 119 | + |
| 120 | + let _ = command.create_followup(ctx.clone(), response).await; |
| 121 | + } |
109 | 122 | }); |
110 | 123 |
|
111 | 124 | Ok(()) |
|
0 commit comments