Skip to content

Commit 7fd57a4

Browse files
committed
refactor(anonreply): implement snippet logic to be able to send snippet message through anonreply command
1 parent 94117e0 commit 7fd57a4

1 file changed

Lines changed: 7 additions & 19 deletions

File tree

rustmail/src/commands/anonreply/text_command/anonreply.rs

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ pub async fn anonreply(
2121
.as_ref()
2222
.ok_or_else(database_connection_failed)?;
2323

24-
let mut content = extract_reply_content(&msg.content, &config.command.prefix, &["anonreply", "ar"]);
25-
24+
let mut content =
25+
extract_reply_content(&msg.content, &config.command.prefix, &["anonreply", "ar"]);
26+
2627
if let Some(text) = &content {
2728
if let Some(stripped) = text.strip_prefix("{{").and_then(|s| s.strip_suffix("}}")) {
2829
let snippet_key = stripped.trim();
@@ -31,9 +32,9 @@ pub async fn anonreply(
3132
content = Some(snippet.content);
3233
}
3334
None => {
34-
msg.reply(&ctx.http, format!("❌ Snippet `{}` not found.", snippet_key))
35-
.await?;
36-
return Ok(());
35+
return Err(ModmailError::Command(CommandError::SnippetNotFound(
36+
snippet_key.to_string(),
37+
)));
3738
}
3839
}
3940
}
@@ -42,20 +43,7 @@ pub async fn anonreply(
4243
let intent = extract_intent(content, &msg.attachments).await;
4344

4445
let Some(intent) = intent else {
45-
MessageBuilder::system_message(&ctx, config)
46-
.translated_content(
47-
"reply.missing_content",
48-
None,
49-
Some(msg.author.id),
50-
msg.guild_id.map(|g| g.get()),
51-
)
52-
.await
53-
.color(0xFF0000)
54-
.reply_to(msg.clone())
55-
.send_and_forget()
56-
.await;
57-
58-
return Err(validation_failed("Missing content"));
46+
return Err(ModmailError::Message(MessageError::MessageEmpty));
5947
};
6048

6149
let thread = fetch_thread(db_pool, &msg.channel_id.to_string()).await?;

0 commit comments

Comments
 (0)