From 5e7964ae26b97ba668deb725fc303bda295c3f95 Mon Sep 17 00:00:00 2001 From: Brendan Golden Date: Mon, 30 Sep 2024 00:03:03 +0100 Subject: [PATCH] feat: some cleanup in messages and added some handrails so folks wont add stupid combos --- src/commands/role_adder.rs | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/src/commands/role_adder.rs b/src/commands/role_adder.rs index 3f224ef..08e0286 100644 --- a/src/commands/role_adder.rs +++ b/src/commands/role_adder.rs @@ -61,6 +61,13 @@ pub mod edit { return "Please provide a valid role for ``Role Current``".to_string(); }; + if role_a == role_b { + return "Roles A and B must be different".to_string(); + } + + if (role_c == role_a)|| (role_c == role_b) { + return "Role C cannot be same as A or B".to_string(); + } let mut delete = false; @@ -86,8 +93,9 @@ pub mod edit { }; let db = db_lock.read().await; + let server = command.guild_id.unwrap_or_default(); let server_data = RoleAdder { - server: command.guild_id.unwrap_or_default(), + server, role_a, role_b, role_c, @@ -101,7 +109,29 @@ pub mod edit { } } - "Added/Updated server info".to_string() + + let mut role_a_name = String::new(); + let mut role_b_name = String::new(); + let mut role_c_name = String::new(); + + if let Ok(x) = server.roles(&ctx).await { + if let Some(y) = x.get(&role_a){ + role_a_name = y.to_owned().name; + } + if let Some(y) = x.get(&role_b){ + role_b_name = y.to_owned().name; + } + if let Some(y) = x.get(&role_b){ + role_c_name = y.to_owned().name; + } + } + + + if delete { + format!("Removed {} + {} = {}", role_a_name, role_b_name, role_c_name) + } else { + format!("Added {} + {} = {}", role_a_name, role_b_name, role_c_name) + } } pub fn register(command: &mut CreateApplicationCommand) -> &mut CreateApplicationCommand {