22 crate :: {
33 actors:: bot_actor:: ActorUpdateMessage ,
44 commands:: { admin_check, guardian_lookup, match_command, validate_username} ,
5- BotCommand ,
5+ render_template_or_err , BotCommand ,
66 } ,
77 entity:: guardians,
88 kameo:: message:: Context ,
1212command_actor ! ( EditGuardianCommand , [ ActorUpdateMessage ] ) ;
1313
1414impl EditGuardianCommand {
15- async fn editguar_usage ( & self , message : & ActorUpdateMessage ) {
16- self . send_reply (
17- message,
18- "Edit guardian command help:
19-
20- /editguar @Telegram NewPsnName
21- Change a guardian's PSN name (admin-only)." ,
22- )
23- . await ;
15+ async fn usage ( & self , message : & ActorUpdateMessage ) {
16+ self . send_reply ( message, render_template_or_err ! ( "editguar/usage" ) )
17+ . await ;
2418 }
2519}
2620
@@ -42,19 +36,13 @@ impl Message<ActorUpdateMessage> for EditGuardianCommand {
4236 message : ActorUpdateMessage ,
4337 _ctx : & mut Context < Self , Self :: Reply > ,
4438 ) -> Self :: Reply {
45- self . handle_message ( message) . await ;
46- }
47- }
48-
49- impl EditGuardianCommand {
50- async fn handle_message ( & self , message : ActorUpdateMessage ) {
5139 let connection = self . connection ( ) ;
5240
5341 if let ( Some ( _) , args) =
5442 match_command ( message. update . text ( ) , Self :: prefix ( ) , & self . bot_name )
5543 {
5644 if args. is_none ( ) {
57- return self . editguar_usage ( & message) . await ;
45+ return self . usage ( & message) . await ;
5846 }
5947
6048 // Split args in two or three:
@@ -65,7 +53,7 @@ impl EditGuardianCommand {
6553 let args: Vec < & str > = args. splitn ( 3 , ' ' ) . collect ( ) ;
6654
6755 if args. is_empty ( ) || args. len ( ) == 2 {
68- return self . editguar_usage ( & message) . await ;
56+ return self . usage ( & message) . await ;
6957 }
7058
7159 let name = args[ 0 ] ;
@@ -80,19 +68,19 @@ impl EditGuardianCommand {
8068 let admin = admin_check ( & self . bot_ref , & message, connection) . await ;
8169
8270 if admin. is_none ( ) {
83- return self . send_reply ( & message, "You are not admin" ) . await ;
71+ return self . send_reply ( & message, "❌ You are not admin" ) . await ;
8472 }
8573
8674 let guardian = guardian_lookup ( name, connection) . await ;
8775 let guardian = match guardian {
8876 Ok ( Some ( guardian) ) => Some ( guardian) ,
8977 Ok ( None ) => {
90- self . send_reply ( & message, format ! ( "Guardian {} was not found." , & name) )
78+ self . send_reply ( & message, format ! ( "❌ Guardian {} was not found." , & name) )
9179 . await ;
9280 None
9381 }
9482 Err ( _) => {
95- self . send_reply ( & message, "Error querying guardian by name." )
83+ self . send_reply ( & message, "❌ Error querying guardian by name." )
9684 . await ;
9785 None
9886 }
@@ -132,9 +120,10 @@ impl EditGuardianCommand {
132120 let mut guardian: guardians:: ActiveModel = guardian. into ( ) ;
133121 guardian. psn_name = Set ( value. to_string ( ) ) ;
134122 if guardian. update ( connection) . await . is_err ( ) {
135- return self . send_reply ( & message, "Failed to update PSN" ) . await ;
123+ return self . send_reply ( & message, "❌ Failed to update PSN" ) . await ;
136124 }
137- self . send_reply ( & message, "PSN updated successfully" ) . await ;
125+ self . send_reply ( & message, "✅ PSN updated successfully" )
126+ . await ;
138127 }
139128 "clan" => {
140129 let clan_value = if value == "delete" {
@@ -145,9 +134,9 @@ impl EditGuardianCommand {
145134 let mut guardian: guardians:: ActiveModel = guardian. into ( ) ;
146135 guardian. psn_clan = Set ( clan_value) ;
147136 if guardian. update ( connection) . await . is_err ( ) {
148- return self . send_reply ( & message, "Failed to update clan" ) . await ;
137+ return self . send_reply ( & message, "❌ Failed to update clan" ) . await ;
149138 }
150- self . send_reply ( & message, "Updated guardian clan" ) . await ;
139+ self . send_reply ( & message, "✅ Updated guardian clan" ) . await ;
151140 }
152141 "email" => {
153142 let email_value = if value == "delete" {
@@ -158,12 +147,13 @@ impl EditGuardianCommand {
158147 let mut guardian: guardians:: ActiveModel = guardian. into ( ) ;
159148 guardian. email = Set ( email_value) ;
160149 if guardian. update ( connection) . await . is_err ( ) {
161- return self . send_reply ( & message, "Failed to update email" ) . await ;
150+ return self . send_reply ( & message, "❌ Failed to update email" ) . await ;
162151 }
163- self . send_reply ( & message, "Updated guardian email" ) . await ;
152+ self . send_reply ( & message, "✅ Updated guardian email" ) . await ;
164153 }
165154 _ => {
166- self . send_reply ( & message, "Unknown information field" ) . await ;
155+ self . send_reply ( & message, "⁉️ Unknown information field" )
156+ . await ;
167157 }
168158 }
169159 }
0 commit comments