11use crate :: abstraction:: command:: { CommandContext , CommandResult } ;
2+ use crate :: abstraction:: components_v2:: { self , Status } ;
23use crate :: command:: { RETROREALM_SERVER_ID , UPDATE_ROLE_ID } ;
34use log:: warn;
45use serenity:: all:: RoleId ;
@@ -13,32 +14,45 @@ use std::str::FromStr;
1314) ]
1415pub async fn toggle_update_role ( ctx : CommandContext < ' _ > ) -> CommandResult {
1516 if UPDATE_ROLE_ID . is_empty ( ) {
16- ctx. say ( "This command is not configured" ) . await ?;
17+ ctx. send ( components_v2:: status_reply (
18+ Status :: Error ,
19+ "This command is not configured." ,
20+ ) )
21+ . await ?;
1722 warn ! ( "UPDATE_ROLE_ID is not set, toggle_update_role command cannot be used!" ) ;
1823 return Ok ( ( ) ) ;
1924 }
2025
2126 let member = ctx. author_member ( ) . await ;
2227
2328 if member. is_none ( ) || ctx. guild_id ( ) . map ( |g| g. get ( ) ) != Some ( * RETROREALM_SERVER_ID ) {
24- ctx. say ( "This command can only be run inside RetroRealm's Discord Server" )
25- . await ?;
29+ ctx. send ( components_v2:: status_reply (
30+ Status :: Error ,
31+ "This command can only be run inside RetroRealm's Discord Server." ,
32+ ) )
33+ . await ?;
2634 return Ok ( ( ) ) ;
2735 }
2836
29- let member = member. unwrap_or_default ( ) ; // safe to unwrap because we checked above
37+ let member = member. unwrap_or_default ( ) ;
38+ let role_id = RoleId :: from_str ( & UPDATE_ROLE_ID ) ?;
3039
31- let role_id = & RoleId :: from_str ( & UPDATE_ROLE_ID ) ?;
32-
33- if member. roles . contains ( role_id) {
34- member. remove_role ( ctx, role_id) . await ?;
35-
36- ctx. say ( "Update Role Removed!" ) . await ?;
40+ if member. roles . contains ( & role_id) {
41+ member. remove_role ( ctx. http ( ) , role_id, None ) . await ?;
42+ ctx. send ( components_v2:: status_reply (
43+ Status :: Success ,
44+ "Update Role Removed!" ,
45+ ) )
46+ . await ?;
3747 return Ok ( ( ) ) ;
3848 }
3949
40- member. add_role ( ctx, role_id) . await ?;
41- ctx. say ( "Update Role Added!" ) . await ?;
50+ member. add_role ( ctx. http ( ) , role_id, None ) . await ?;
51+ ctx. send ( components_v2:: status_reply (
52+ Status :: Success ,
53+ "Update Role Added!" ,
54+ ) )
55+ . await ?;
4256
4357 Ok ( ( ) )
4458}
0 commit comments