Still got errors and warnings, mostly the same and easy to fix
diff --git a/src/api/index.ts b/src/api/index.ts
index 5cc4a99..1750509 100644
--- a/src/api/index.ts
+++ b/src/api/index.ts
@@ -1,9 +1,9 @@
-import { HaikuClient } from 'jshaiku';
-import express from 'express';
-import bodyParser from 'body-parser';
+import type { HaikuClient } from "jshaiku";
+import express from "express";
+import bodyParser from "body-parser";
import EmojiEmbed from "../utils/generateEmojiEmbed.js";
-import structuredClone from '@ungap/structured-clone';
-import client from '../utils/client.js';
+import structuredClone from "@ungap/structured-clone";
+import client from "../utils/client.js";
const jsonParser = bodyParser.json();
@@ -11,38 +11,38 @@
const port = 10000;
const runServer = (client: HaikuClient) => {
- app.get('/', (req, res) => {
+ app.get("/", (req, res) => {
res.status(200).send(client.ws.ping);
});
- app.post('/verify/:code', jsonParser, async function (req, res) {
+ app.post("/verify/:code", jsonParser, async function (req, res) {
const code = req.params.code;
const secret = req.body.secret;
if (secret === client.config.verifySecret) {
- let guild = await client.guilds.fetch(client.verify[code].gID);
- if (!guild) { return res.status(404) }
- let member = await guild.members.fetch(client.verify[code].uID);
- if (!member) { return res.status(404) }
- if (member.roles.cache.has(client.verify[code].rID)) { return res.status(200) }
+ const guild = await client.guilds.fetch(client.verify[code].gID);
+ if (!guild) { return res.status(404); }
+ const member = await guild.members.fetch(client.verify[code].uID);
+ if (!member) { return res.status(404); }
+ if (member.roles.cache.has(client.verify[code].rID)) { return res.status(200); }
await member.roles.add(client.verify[code].rID);
- let interaction = client.verify[code].interaction;
+ const interaction = client.verify[code].interaction;
if (interaction) {
interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Verify")
- .setDescription(`Verification complete`)
+ .setDescription("Verification complete")
.setStatus("Success")
.setEmoji("MEMBER.JOIN")
], components: []});
}
delete client.verify[code];
- const { log, NucleusColors, entry, renderUser } = client.logger
+ const { log, NucleusColors, entry, renderUser } = client.logger;
try {
- let data = {
+ const data = {
meta:{
- type: 'memberVerify',
- displayName: 'Member Verified',
- calculateType: 'guildMemberVerify',
+ type: "memberVerify",
+ displayName: "Member Verified",
+ calculateType: "guildMemberVerify",
color: NucleusColors.green,
emoji: "CONTROL.BLOCKTICK",
timestamp: new Date().getTime()
@@ -54,74 +54,76 @@
hidden: {
guild: guild.id
}
- }
+ };
log(data);
- } catch {}
+ } catch {
+ res.sendStatus(500);
+ }
res.sendStatus(200);
} else {
res.sendStatus(403);
}
});
- app.get('/verify/:code', jsonParser, function (req, res) {
+ app.get("/verify/:code", jsonParser, function (req, res) {
const code = req.params.code;
if (client.verify[code]) {
try {
- let interaction = client.verify[code].interaction;
+ const 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`)
+ .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])
+ } catch { return res.sendStatus(410); }
+ const data = structuredClone(client.verify[code]);
delete data.interaction;
return res.status(200).send(data);
}
return res.sendStatus(404);
- })
+ });
- app.post('/rolemenu/:code', jsonParser, async function (req, res) {
+ 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) {
- let guild = await client.guilds.fetch(client.roleMenu[code].guild);
- if (!guild) { return res.status(404) }
- let member = await guild.members.fetch(client.roleMenu[code].user);
- if (!member) { return res.status(404) }
+ const guild = await client.guilds.fetch(client.roleMenu[code].guild);
+ if (!guild) { return res.status(404); }
+ const 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) {
+ 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;
+ const 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`)
+ .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])
+ } catch { return res.sendStatus(410); }
+ const data = structuredClone(client.roleMenu[code]);
delete data.interaction;
- console.log(data)
+ console.log(data);
return res.status(200).send(data);
}
return res.sendStatus(404);
- })
+ });
app.listen(port);
-}
+};
export default runServer;
\ No newline at end of file