From 483875609b75c0e0a3e6f6d83badffd61f92ebe7 Mon Sep 17 00:00:00 2001 From: Nahokey Date: Sun, 28 Apr 2024 18:55:18 +0000 Subject: [PATCH] Added another function into DangerCord function file. --- functions/dangerCordUtils.js | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/functions/dangerCordUtils.js b/functions/dangerCordUtils.js index 11187da..c59d4de 100644 --- a/functions/dangerCordUtils.js +++ b/functions/dangerCordUtils.js @@ -21,11 +21,11 @@ async function dangercordcheckVerification(userId, accessToken) { return 1; // Allowed to continue } else { // Determine if report level is acceptable - if (userData.reports >= 1 && userData.last_reported >= Date.now() - (30 * 24 * 60 * 60 * 1000)) { - return 0; // Not allowed to continue - } else { - return 1; // Allowed to continue -} + if (userData.reports >= 1 && userData.last_reported >= Date.now() - (30 * 24 * 60 * 60 * 1000)) { + return 0; // Not allowed to continue + } else { + return 1; // Allowed to continue + } } } catch (error) { console.error('Error fetching user data:', error); @@ -33,4 +33,21 @@ async function dangercordcheckVerification(userId, accessToken) { } } -module.exports = { dangercordcheckVerification }; +async function dangercordcheckInfo(userId, accessToken) { + const url = `https://dangercord.com/api/v1/user/${userId}`; + const headers = { + 'Authorization': `Bearer ${cfg.dangerCordAPIKey}` + }; + + try { + const response = await fetch(url, { headers }); + const userData = await response.json(); + + return userData; + } catch (error) { + console.error('Error fetching user data:', error); + return; + } +} + +module.exports = { dangercordcheckVerification, dangercordcheckInfo };