Skip to content

Commit 4759ba8

Browse files
authored
Merge pull request #153 from Rustmail/152-bug-wrong-behavior-for-move-command-only-slash-command
fix(slash_command): fix for incorrect behavior of slash commands following an error
2 parents 2ebc3b0 + cd1a110 commit 4759ba8

3 files changed

Lines changed: 9 additions & 14 deletions

File tree

src/commands/edit/message_ops.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use crate::config::Config;
2-
use crate::db::messages::{get_thread_message_by_inbox_message_id, MessageIds};
2+
use crate::db::messages::{MessageIds, get_thread_message_by_inbox_message_id};
33
use crate::db::operations::{
44
get_message_ids_by_number, get_thread_by_channel_id, get_user_id_from_channel_id,
55
};
6-
use crate::errors::common::{incorrect_message_id, not_found, permission_denied, thread_not_found};
76
use crate::errors::MessageError::{DmAccessFailed, EditFailed};
7+
use crate::errors::common::{incorrect_message_id, not_found, permission_denied, thread_not_found};
88
use crate::errors::{ModmailError, ModmailResult};
99
use crate::utils::conversion::hex_string_to_int::hex_string_to_int;
1010
use crate::utils::message::message_builder::MessageBuilder;

src/commands/move_thread/slash_command/move_thread.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::utils::command::defer_response::defer_response;
1111
use crate::utils::message::message_builder::MessageBuilder;
1212
use serenity::all::{
1313
CommandInteraction, CommandOptionType, Context, CreateCommand, CreateCommandOption,
14-
CreateInteractionResponse, ResolvedOption,
14+
ResolvedOption,
1515
};
1616
use std::collections::HashMap;
1717

@@ -109,12 +109,10 @@ pub async fn run(
109109
)
110110
.await
111111
.to_channel(command.channel_id)
112-
.build_interaction_message()
112+
.build_interaction_message_followup()
113113
.await;
114114

115-
command
116-
.create_response(&ctx.http, CreateInteractionResponse::Message(response))
117-
.await?;
115+
command.create_followup(&ctx.http, response).await?;
118116

119117
Ok(())
120118
}

src/errors/handler.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ use crate::errors::dictionary::DictionaryManager;
33
use crate::errors::types::{ModmailError, ModmailResult};
44
use crate::i18n::languages::{Language, LanguageDetector, LanguagePreferences};
55
use serenity::all::{
6-
ChannelId, Colour, CommandInteraction, Context, CreateEmbed, CreateInteractionResponseMessage,
6+
ChannelId, Colour, CommandInteraction, Context, CreateEmbed, CreateInteractionResponseFollowup,
77
CreateMessage, Message, UserId,
88
};
9-
use serenity::builder::CreateInteractionResponse;
109
use std::collections::HashMap;
1110
use std::sync::Arc;
1211
use tokio::sync::RwLock;
@@ -154,7 +153,7 @@ impl ErrorHandler {
154153
ctx: &Context,
155154
command: &CommandInteraction,
156155
error: &ModmailError,
157-
) -> Result<(), serenity::Error> {
156+
) -> Result<Message, serenity::Error> {
158157
let formatted_error = self
159158
.handle_error(
160159
error,
@@ -166,11 +165,9 @@ impl ErrorHandler {
166165
let embed = self.create_error_embed(&formatted_error).await;
167166

168167
command
169-
.create_response(
168+
.create_followup(
170169
&ctx.http,
171-
CreateInteractionResponse::Message(
172-
CreateInteractionResponseMessage::new().embed(embed),
173-
),
170+
CreateInteractionResponseFollowup::new().embed(embed),
174171
)
175172
.await
176173
}

0 commit comments

Comments
 (0)