From 55ae57b4cc79605e5244455b09908f962e98177d Mon Sep 17 00:00:00 2001
From: Toastie <toastie@toastiet0ast.com>
Date: Sat, 18 Jan 2025 22:57:28 +1300
Subject: [PATCH] .sar rm will now accept role ids, in the role is deleted

---
 .../SelfAssignedRolesCommands.cs                | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/src/EllieBot/Modules/Administration/SelfAssignableRoles/SelfAssignedRolesCommands.cs b/src/EllieBot/Modules/Administration/SelfAssignableRoles/SelfAssignedRolesCommands.cs
index 287ac4e..b1352cc 100644
--- a/src/EllieBot/Modules/Administration/SelfAssignableRoles/SelfAssignedRolesCommands.cs
+++ b/src/EllieBot/Modules/Administration/SelfAssignableRoles/SelfAssignedRolesCommands.cs
@@ -192,15 +192,22 @@ public partial class Administration
         [Cmd]
         [RequireContext(ContextType.Guild)]
         [UserPerm(GuildPerm.ManageRoles)]
-        public async Task SarRemove([Leftover] IRole role)
-        {
-            var guser = (IGuildUser)ctx.User;
+        [Priority(1)]
+        public Task SarRemove([Leftover] IRole role)
+            => SarRemove(role.Id);
 
-            var success = await _service.RemoveAsync(role.Guild.Id, role.Id);
+        [Cmd]
+        [RequireContext(ContextType.Guild)]
+        [UserPerm(GuildPerm.ManageRoles)]
+        [Priority(0)]
+        public async Task SarRemove([Leftover] ulong roleId)
+        {
+            var role = await ctx.Guild.GetRoleAsync(roleId);
+            var success = await _service.RemoveAsync(ctx.Guild.Id, roleId);
             if (!success)
                 await Response().Error(strs.self_assign_not).SendAsync();
             else
-                await Response().Confirm(strs.self_assign_rem(Format.Bold(role.Name))).SendAsync();
+                await Response().Confirm(strs.self_assign_rem(Format.Bold(role?.Name ?? roleId.ToString()))).SendAsync();
         }
 
         [Cmd]