From 586f9c8f0743bb56749d5130693de4813b061a28 Mon Sep 17 00:00:00 2001 From: Toastie Date: Fri, 27 Dec 2024 18:18:23 +1300 Subject: [PATCH] Improved feedback message for /addstaff when user is already staff --- Commands/AddStaffCommand.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Commands/AddStaffCommand.cs b/Commands/AddStaffCommand.cs index 26a11cf..adf789a 100644 --- a/Commands/AddStaffCommand.cs +++ b/Commands/AddStaffCommand.cs @@ -43,8 +43,10 @@ public class AddStaffCommand return; } + bool alreadyStaff = Database.IsStaff(staffMember.Id); + await using MySqlConnection c = Database.GetConnection(); - MySqlCommand cmd = Database.IsStaff(staffMember.Id) ? new MySqlCommand(@"UPDATE staff SET name = @name WHERE user_id = @user_id", c) : new MySqlCommand(@"INSERT INTO staff (user_id, name) VALUES (@user_id, @name);", c); + MySqlCommand cmd = alreadyStaff ? new MySqlCommand(@"UPDATE staff SET name = @name WHERE user_id = @user_id", c) : new MySqlCommand(@"INSERT INTO staff (user_id, name) VALUES (@user_id, @name);", c); c.Open(); cmd.Parameters.AddWithValue("@user_id", staffMember.Id); @@ -55,7 +57,7 @@ public class AddStaffCommand await command.RespondAsync(new DiscordEmbedBuilder { Color = DiscordColor.Green, - Description = staffMember.Mention + " was added to staff." + Description = alreadyStaff ? staffMember.Mention + " is already a staff member, refreshed username in database." : staffMember.Mention + " was added to staff." }, true); try