diff --git a/src/api/index.ts b/src/api/index.ts
index 00c866d..b2edc66 100644
--- a/src/api/index.ts
+++ b/src/api/index.ts
@@ -18,7 +18,6 @@
     app.post('/verify/:code', jsonParser, async function (req, res) {
         const code = req.params.code;
         const secret = req.body.secret;
-        const { log, NucleusColors, entry, renderUser } = client.logger
         if (secret === client.config.verifySecret) {
             let guild = await client.guilds.fetch(client.verify[code].gID);
             if (!guild) { return res.status(404) }
@@ -36,6 +35,8 @@
                     .setEmoji("MEMBER.JOIN")
                 ], components: []});
             }
+            delete client.verify[code];
+            const { log, NucleusColors, entry, renderUser } = client.logger
             try {
                 let data = {
                     meta:{
@@ -47,7 +48,7 @@
                         timestamp: new Date().getTime()
                     },
                     list: {
-                        id: entry(member.id, `\`${member.id}\``),
+                        memberId: entry(member.id, `\`${member.id}\``),
                         member: entry(member.id, renderUser(member))
                     },
                     hidden: {
@@ -62,25 +63,20 @@
         }
     });
 
-    app.patch('/verify/:code', (req, res) => {
-        const code = req.params.code;
-        try {
-            let interaction = client.verify[code].interaction;
-            if (interaction) {
-                interaction.editReply({embeds: [new EmojiEmbed()
-                    .setTitle("Verify")
-                    .setDescription(`Verify was opened in another tab or window, please complete the CAPTCHA there to continue`)
-                    .setStatus("Success")
-                    .setEmoji("MEMBER.JOIN")
-                ]});
-            }
-        } catch {}
-        res.sendStatus(200);
-    })
-
     app.get('/verify/:code', jsonParser, function (req, res) {
         const code = req.params.code;
         if (client.verify[code]) {
+            try {
+                let interaction = client.verify[code].interaction;
+                if (interaction) {
+                    interaction.editReply({embeds: [new EmojiEmbed()
+                        .setTitle("Verify")
+                        .setDescription(`Verify was opened in another tab or window, please complete the CAPTCHA there to continue`)
+                        .setStatus("Success")
+                        .setEmoji("MEMBER.JOIN")
+                    ]});
+                }
+            } catch {}
             let data = structuredClone(client.verify[code])
             delete data.interaction;
             return res.status(200).send(data);
@@ -88,6 +84,44 @@
         return res.sendStatus(404);
     })
 
+    app.post('/rolemenu/:code', jsonParser, async function (req, res) {
+        const code = req.params.code;
+        const secret = req.body.secret;
+        const data = req.body.data;
+        if (secret === client.config.verifySecret) {
+            console.table(data)
+            let guild = await client.guilds.fetch(client.roleMenu[code].guild); // TODO: do checks here to like max roles because people are fucking annoying and will edit the source :)
+            if (!guild) { return res.status(404) }
+            let member = await guild.members.fetch(client.roleMenu[code].user);
+            if (!member) { return res.status(404) }
+            res.sendStatus(200);
+        } else {
+            res.sendStatus(403);
+        }
+    });
+
+    app.get('/rolemenu/:code', jsonParser, function (req, res) {
+        const code = req.params.code;
+        if (client.roleMenu[code] !== undefined) {
+            try {
+                let interaction = client.roleMenu[code].interaction;
+                if (interaction) {
+                    interaction.editReply({embeds: [new EmojiEmbed()
+                        .setTitle("Roles")
+                        .setDescription(`The role menu was opened in another tab or window, please select your roles there to continue`)
+                        .setStatus("Success")
+                        .setEmoji("GUILD.GREEN")
+                    ], components: []});
+                }
+            } catch {}
+            let data = structuredClone(client.roleMenu[code])
+            delete data.interaction;
+            console.log(data)
+            return res.status(200).send(data);
+        }
+        return res.sendStatus(404);
+    })
+
     app.listen(port);
 }
 
