Skip to content

Commit 94117e0

Browse files
committed
refactor(reply): implement snippet logic to be able to send snippet message through reply command
1 parent 093ab11 commit 94117e0

2 files changed

Lines changed: 15 additions & 6 deletions

File tree

rustmail/src/commands/reply/slash_command/reply.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,15 @@ impl RegistrableCommand for ReplyCommand {
6060
None,
6161
)
6262
.await;
63+
let snippet_desc = get_translated_message(
64+
&config,
65+
"slash_command.reply_snippet_argument_description",
66+
None,
67+
None,
68+
None,
69+
None,
70+
)
71+
.await;
6372
let anonymous_desc = get_translated_message(
6473
&config,
6574
"slash_command.reply_anonymous_argument_description",
@@ -85,7 +94,7 @@ impl RegistrableCommand for ReplyCommand {
8594
CreateCommandOption::new(
8695
CommandOptionType::String,
8796
"snippet",
88-
"Use a snippet instead of typing a message",
97+
snippet_desc,
8998
)
9099
.required(false),
91100
)
@@ -157,8 +166,8 @@ impl RegistrableCommand for ReplyCommand {
157166
content = Some(snippet.content);
158167
}
159168
None => {
160-
return Err(ModmailError::Command(CommandError::CommandFailed(
161-
format!("Snippet '{}' not found", key),
169+
return Err(ModmailError::Command(CommandError::SnippetNotFound(
170+
key.to_string(),
162171
)));
163172
}
164173
}

rustmail/src/commands/reply/text_command/reply.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ pub async fn reply(
3131
content = Some(snippet.content);
3232
}
3333
None => {
34-
msg.reply(&ctx.http, format!("❌ Snippet `{}` not found.", snippet_key))
35-
.await?;
36-
return Ok(());
34+
return Err(ModmailError::Command(CommandError::SnippetNotFound(
35+
snippet_key.to_string(),
36+
)));
3737
}
3838
}
3939
}

0 commit comments

Comments
 (0)