@@ -79,7 +79,15 @@ impl RegistrableCommand for ReplyCommand {
7979 "message" ,
8080 message_desc,
8181 )
82- . required( true ) ,
82+ . required( false ) ,
83+ )
84+ . add_option(
85+ CreateCommandOption :: new(
86+ CommandOptionType :: String ,
87+ "snippet" ,
88+ "Use a snippet instead of typing a message" ,
89+ )
90+ . required( false ) ,
8391 )
8492 . add_option(
8593 CreateCommandOption :: new(
@@ -119,6 +127,7 @@ impl RegistrableCommand for ReplyCommand {
119127 defer_response ( & ctx, & command) . await ?;
120128
121129 let mut content: Option < String > = None ;
130+ let mut snippet_key: Option < String > = None ;
122131 let mut attachments: Vec < Attachment > = Vec :: new ( ) ;
123132 let mut anonymous: bool = false ;
124133
@@ -127,6 +136,9 @@ impl RegistrableCommand for ReplyCommand {
127136 CommandDataOptionValue :: String ( val) if option. name == "message" => {
128137 content = Some ( val. clone ( ) ) ;
129138 }
139+ CommandDataOptionValue :: String ( val) if option. name == "snippet" => {
140+ snippet_key = Some ( val. clone ( ) ) ;
141+ }
130142 CommandDataOptionValue :: Attachment ( att_id) if option. name == "attachment" => {
131143 if let Some ( att) = command. data . resolved . attachments . get ( att_id) {
132144 attachments. push ( att. clone ( ) ) ;
@@ -138,6 +150,19 @@ impl RegistrableCommand for ReplyCommand {
138150 _ => { }
139151 }
140152 }
153+
154+ if let Some ( key) = snippet_key {
155+ match get_snippet_by_key ( & key, db_pool) . await ? {
156+ Some ( snippet) => {
157+ content = Some ( snippet. content ) ;
158+ }
159+ None => {
160+ return Err ( ModmailError :: Command ( CommandError :: CommandFailed (
161+ format ! ( "Snippet '{}' not found" , key) ,
162+ ) ) ) ;
163+ }
164+ }
165+ }
141166
142167 let intent = extract_intent ( content, & attachments) . await ;
143168
0 commit comments