diff --git a/src/commands/role/user.ts b/src/commands/role/user.ts
index ac94b47..ad29811 100644
--- a/src/commands/role/user.ts
+++ b/src/commands/role/user.ts
@@ -1,5 +1,5 @@
-import { CommandInteraction, GuildMember, Role } from "discord.js";
-import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
+import type { CommandInteraction, GuildMember, Role, User } from "discord.js";
+import type { SlashCommandSubcommandBuilder } from "@discordjs/builders";
 import client from "../../utils/client.js";
 import confirmationMessage from "../../utils/confirmationMessage.js";
 import keyValueList from "../../utils/generateKeyValueList.js";
@@ -28,79 +28,68 @@
 
 const callback = async (interaction: CommandInteraction): Promise<unknown> => {
     const { renderUser, renderRole } = client.logger;
-    const action = interaction.options.getString("action");
+    const action = interaction.options.get("action")?.value as string;
+    const role: Role = (await interaction.guild!.roles.fetch(interaction.options.get("role")?.value as string))!;
     // TODO:[Modals] Replace this with a modal
     const confirmation = await new confirmationMessage(interaction)
         .setEmoji("GUILD.ROLES.DELETE")
         .setTitle("Role")
         .setDescription(
             keyValueList({
-                user: renderUser(interaction.options.getUser("user")),
-                role: renderRole(interaction.options.get("role"))
+                user: renderUser(interaction.options.getUser("user")! as User),
+                role: renderRole(role)
             }) +
                 `\nAre you sure you want to ${
                     action === "give" ? "give the role to" : "remove the role from"
                 } ${interaction.options.getUser("user")}?`
         )
         .setColor("Danger")
+        .setFailedMessage("No changes were made", "Success", "GUILD.ROLES.CREATE")
         .send();
-    if (confirmation.cancelled) return;
-    if (confirmation.success) {
-        try {
-            const member = interaction.options.getMember("user") as GuildMember;
-            const role = interaction.options.get("role") as unknown as Role;
-            if (interaction.options.getString("action") === "give") {
-                member.roles.add(role);
-            } else {
-                member.roles.remove(role);
-            }
-        } catch (e) {
-            return await interaction.editReply({
-                embeds: [
-                    new EmojiEmbed()
-                        .setTitle("Role")
-                        .setDescription("Something went wrong and the role could not be added")
-                        .setStatus("Danger")
-                        .setEmoji("CONTROL.BLOCKCROSS")
-                ],
-                components: []
-            });
+    if (confirmation.cancelled || !confirmation.success) return;
+    try {
+        const member = interaction.options.getMember("user") as GuildMember;
+        if ((interaction.options.get("action")?.value as string) === "give") {
+            member.roles.add(role);
+        } else {
+            member.roles.remove(role);
         }
+    } catch (e) {
         return await interaction.editReply({
             embeds: [
                 new EmojiEmbed()
                     .setTitle("Role")
-                    .setDescription(`The role has been ${action === "give" ? "given" : "removed"} successfully`)
-                    .setStatus("Success")
-                    .setEmoji("GUILD.ROLES.CREATE")
-            ],
-            components: []
-        });
-    } else {
-        await interaction.editReply({
-            embeds: [
-                new EmojiEmbed()
-                    .setEmoji("GUILD.ROLES.CREATE")
-                    .setTitle("Role")
-                    .setDescription("No changes were made.")
+                    .setDescription("Something went wrong and the role could not be added")
                     .setStatus("Danger")
+                    .setEmoji("CONTROL.BLOCKCROSS")
             ],
             components: []
         });
     }
+    return await interaction.editReply({
+        embeds: [
+            new EmojiEmbed()
+                .setTitle("Role")
+                .setDescription(`The role has been ${action === "give" ? "given" : "removed"} successfully`)
+                .setStatus("Success")
+                .setEmoji("GUILD.ROLES.CREATE")
+        ],
+        components: []
+    });
 };
 
 const check = (interaction: CommandInteraction) => {
     const member = interaction.member as GuildMember;
-    const me = interaction.guild.me!;
+    if (!interaction.guild) return
+    const me = interaction.guild.members.me!;
     const apply = interaction.options.getMember("user") as GuildMember | null;
-    if (apply === null) throw new Error("That member is not in the server");
+    if (apply === null) return "That member is not in the server";
     // Check if Nucleus has permission to role
-    if (!me.permissions.has("MANAGE_ROLES")) throw new Error("I do not have the *Manage Roles* permission");
+    if (!me.permissions.has("ManageRoles")) return "I do not have the *Manage Roles* permission";
     // Allow the owner to role anyone
     if (member.id === interaction.guild.ownerId) return true;
     // Check if the user has manage_roles permission
-    if (!member.permissions.has("MANAGE_ROLES")) throw new Error("You do not have the *Manage Roles* permission");
+    if (!member.permissions.has("ManageRoles")) return "You do not have the *Manage Roles* permission";
     // Allow role
     return true;
 };
