diff --git a/src/commands/mod/kick.ts b/src/commands/mod/kick.ts
index 895f035..32cd9fd 100644
--- a/src/commands/mod/kick.ts
+++ b/src/commands/mod/kick.ts
@@ -1,20 +1,92 @@
-import { CommandInteraction } from "discord.js";
+import { CommandInteraction, GuildMember } from "discord.js";
 import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
 import { WrappedCheck } from "jshaiku";
+import confirmationMessage from "../../utils/confirmationMessage.js";
+import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
+import keyValueList from "../../utils/generateKeyValueList.js";
 
 const command = (builder: SlashCommandSubcommandBuilder) =>
     builder
     .setName("kick")
-    .setDescription("Clears a users messages in a channel")
+    .setDescription("Kicks a user from the server")
+    .addUserOption(option => option.setName("user").setDescription("The user to kick").setRequired(true))
+    .addStringOption(option => option.setName("reason").setDescription("The reason for the kick").setRequired(false))
+    .addStringOption(option => option.setName("notify").setDescription("If the user should get a message when they are kicked | Default yes").setRequired(false)
+        .addChoices([["Yes", "yes"], ["No", "no"]])
+    )
 
-const callback = (interaction: CommandInteraction) => {
-    interaction.reply("Command incomplete [mod/kick]");
+const callback = async (interaction: CommandInteraction) => {
+    // TODO:[Modals] Replace this with a modal
+    if (await new confirmationMessage(interaction)
+        .setEmoji("PUNISH.KICK.RED")
+        .setTitle("Kick")
+        .setDescription(keyValueList({
+            "user": `<@!${(interaction.options.getMember("user") as GuildMember).id}> (${(interaction.options.getMember("user") as GuildMember).user.username})`,
+            "reason": `\n> ${interaction.options.getString("reason") ? interaction.options.getString("reason") : "*No reason provided*"}`
+        })
+        + `The user **will${interaction.options.getString("notify") === "no" ? ' not' : ''}** be notified\n\n`
+        + `Are you sure you want to kick <@!${(interaction.options.getMember("user") as GuildMember).id}>?`)
+        .setColor("Danger")
+//        pluralize("day", interaction.options.getInteger("delete"))
+//        const pluralize = (word: string, count: number) => { return count === 1 ? word : word + "s" }
+    .send()) {
+        let dmd = false
+        try {
+            if (interaction.options.getString("notify") != "no") {
+                await (interaction.options.getMember("user") as GuildMember).send({
+                    embeds: [new EmojiEmbed()
+                        .setEmoji("PUNISH.KICK.RED")
+                        .setTitle("Kicked")
+                        .setDescription(`You have been kicked in ${interaction.guild.name}` +
+                                    (interaction.options.getString("reason") ? ` for:\n> ${interaction.options.getString("reason")}` : " with no reason provided."))
+                        .setStatus("Danger")
+                    ]
+                })
+                dmd = true
+            }
+        } catch {}
+        try {
+            (interaction.options.getMember("user") as GuildMember).kick(interaction.options.getString("reason") ?? "No reason provided.")
+            let failed = (dmd == false && interaction.options.getString("notify") != "no")
+            await interaction.editReply({embeds: [new EmojiEmbed()
+                .setEmoji(`PUNISH.KICK.${failed ? "YELLOW" : "GREEN"}`)
+                .setTitle(`Kick`)
+                .setDescription("The member was kicked" + (failed ? ", but could not be notified" : ""))
+                .setStatus(failed ? "Warning" : "Success")
+            ], components: []})
+        } catch {
+            await interaction.editReply({embeds: [new EmojiEmbed()
+                .setEmoji("PUNISH.KICK.RED")
+                .setTitle(`Kick`)
+                .setDescription("Something went wrong and the user was not kicked")
+                .setStatus("Danger")
+            ], components: []})
+        }
+    } else {
+        await interaction.editReply({embeds: [new EmojiEmbed()
+            .setEmoji("PUNISH.KICK.GREEN")
+            .setTitle(`Kick`)
+            .setDescription("No changes were made")
+            .setStatus("Success")
+        ], components: []})
+    }
 }
 
 const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
-    return true;
+    // Check if Nucleus can kick the member
+    if (! (interaction.guild.me.roles.highest.position > (interaction.member as GuildMember).roles.highest.position)) throw "I do not have a role higher than that member"
+    // Check if Nucleus has permission to kick
+    if (! interaction.guild.me.permissions.has("KICK_MEMBERS")) throw "I do not have the `kick_members` permission";
+    // Do not allow kicking Nucleus
+    if ((interaction.member as GuildMember).id == interaction.guild.me.id) throw "I cannot kick myself"
+    // Allow the owner to kick anyone
+    if ((interaction.member as GuildMember).id == interaction.guild.ownerId) return true
+    // Check if the user has kick_members permission
+    if (! (interaction.member as GuildMember).permissions.has("KICK_MEMBERS")) throw "You do not have the `kick_members` permission";
+    // Check if the user is below on the role list
+    if (! ((interaction.member as GuildMember).roles.highest.position > (interaction.options.getMember("user") as GuildMember).roles.highest.position)) throw "You do not have a role higher than that member"
+    // Allow kick
+    return true
 }
 
-export { command };
-export { callback };
-export { check };
\ No newline at end of file
+export { command, callback, check };
\ No newline at end of file
