Skip to content

Commit

Permalink
admin: allow to search by discord id
Browse files Browse the repository at this point in the history
  • Loading branch information
rgerum committed Oct 14, 2024
1 parent a2c3058 commit 7adb710
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/app/admin/users/[user_id]/page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ import { sql } from "@/lib/db";
async function user_properties(id) {
const isNumeric = (value) =>
value.length !== 0 && [...value].every((c) => c >= "0" && c <= "9");
if (isNumeric(id))
if (isNumeric(id)) {
// if it is a discord ID
if(id.length >= 10)
return (await sql`SELECT * FROM users WHERE id = (SELECT "userId" FROM accounts where "providerAccountId" = ${id})`)[0];
return (await sql`SELECT * FROM "users" WHERE id = ${id} LIMIT 1;`)[0];
}
else return (await sql`SELECT * FROM "users" WHERE REPLACE(name, ' ', '') = ${id.replace("%20", "")} LIMIT 1;`)[0];
}

Expand Down

0 comments on commit 7adb710

Please sign in to comment.