diff --git a/package.json b/package.json index f6efe51..d529ab1 100644 --- a/package.json +++ b/package.json @@ -10,8 +10,8 @@ "lint:fix": "eslint ./src/ --fix" }, "devDependencies": { - "@types/node": "^24.0.3", "@types/bun": "^1.2.17", + "@types/node": "^24.0.3", "@typescript-eslint/eslint-plugin": "^8.34.1", "@typescript-eslint/parser": "^8.34.1", "eslint": "^9.29.0", diff --git a/src/commands/manverify.ts b/src/commands/manverify.ts index 0653a26..cdf39cb 100644 --- a/src/commands/manverify.ts +++ b/src/commands/manverify.ts @@ -62,7 +62,10 @@ export default { await db.setData(member.id, ip); await grantRole(interaction.guild, member.id, memberRoles); - await logWebhook(interaction.client, `<@!${user.id}> was manually verified by <@!${interaction.user.id}>.`); + await logWebhook( + interaction.client, + `<@!${user.id}> was manually verified by <@!${interaction.user.id}>.` + ); const embed = new EmbedBuilder() .setTitle("Manually verified.") .setDescription( diff --git a/src/commands/verify.ts b/src/commands/verify.ts index 8c20d9f..63b4260 100644 --- a/src/commands/verify.ts +++ b/src/commands/verify.ts @@ -85,7 +85,7 @@ export default { embeds: [], components: [], }); - }; + } const mainId = await db.checkIp(data.ip); @@ -135,7 +135,10 @@ export default { if (i.customId === "confirm") { await db.setData(user.id, data.ip); await grantRole(interaction.guild!, user.id, memberRoles); - await logWebhook(interaction.client, `<@!${user.id}> was manually verified by <@!${interaction.user.id}>.`); + await logWebhook( + interaction.client, + `<@!${user.id}> was manually verified by <@!${interaction.user.id}>.` + ); //@ts-expect-error const formatter = new Intl.ListFormat("en", { diff --git a/src/index.ts b/src/index.ts index a13738b..629c496 100644 --- a/src/index.ts +++ b/src/index.ts @@ -7,8 +7,9 @@ import { Hono } from "hono"; import { serveStatic } from "hono/bun"; import * as db from "./db/db.ts"; import * as oauth from "./util/oauth.ts"; -import { getIpData } from "./util/ip.ts"; +import { getIpData, getIp } from "./util/ip.ts"; import { checkRole, grantRole, logWebhook } from "./util/discordManager.ts"; + // Initialize the Discord client const client = new Client({ intents: [ @@ -63,7 +64,8 @@ app.get("/callback", async (c) => { if (!code) { return c.redirect("/error.html"); } - const ip = c.req.header("X-Forwarded-For"); + const ip = await getIp(c); + if (!ip) { return c.redirect("/error.html"); } @@ -86,20 +88,29 @@ app.get("/callback", async (c) => { if (await checkRole(guild, id, mutedRole)) { console.log(`${id} tried verifying with muted role`); - await logWebhook(client, `<@!${id}> tried to verify while having the muted role.`); + await logWebhook( + client, + `<@!${id}> tried to verify while having the muted role.` + ); return c.redirect("/altflagged.html"); } if (await checkRole(guild, id, altRole)) { console.log(`${id} tried verifying with alternate role`); - await logWebhook(client, `<@!${id}> tried to verify while having the alternate role.`); + await logWebhook( + client, + `<@!${id}> tried to verify while having the alternate role.` + ); return c.redirect("/altflagged.html"); } const mainId = await db.checkIp(ip); if (mainId && id !== mainId) { - await logWebhook(client, `<@!${id}> was flagged as an alt account. Their main is <@!${mainId}>.`); + await logWebhook( + client, + `<@!${id}> was flagged as an alt account. Their main is <@!${mainId}>.` + ); grantRole(guild, id, altRole); return c.redirect("/altflagged.html"); } @@ -107,12 +118,18 @@ app.get("/callback", async (c) => { const ipData = await getIpData(ip); if (ipData.mobile) { - await logWebhook(client, `<@!${id}> Is trying to verify over a potential mobile data connection.`); + await logWebhook( + client, + `<@!${id}> Is trying to verify over a potential mobile data connection.` + ); return c.redirect("/mobile.html"); } if (ipData.proxy || ipData.hosting) { - await logWebhook(client, `<@!${id}> attempted to verify over a proxy or VPN.`); + await logWebhook( + client, + `<@!${id}> attempted to verify over a proxy or VPN.` + ); return c.redirect("/flagged.html"); } diff --git a/src/public/altflagged.html b/src/public/altflagged.html index 9875c64..f23373e 100644 --- a/src/public/altflagged.html +++ b/src/public/altflagged.html @@ -40,8 +40,11 @@

Flagged

Verification failed. We have detected you have already verified - yourself on this IP Address. If you believe this was a mistake, create - a ticket and explain your situation. + yourself on this IP Address. + If you believe this was a mistake, create a ticket and explain your + situation.