const request = require('request') const fs = require('fs') module.exports = async (app, req, res, api, getLevels) => { if (app.offline) return res.send("-1") let username = getLevels || req.params.id let accountMode = !req.query.hasOwnProperty("player") && Number(req.params.id) let foundID = app.accountCache[username.toLowerCase()] let skipRequest = accountMode || foundID // if you're searching by account id, an intentional error is caused to skip the first request to the gd servers. see i pulled a sneaky on ya. (fuck callbacks man) request.post(skipRequest ? "" : app.endpoint + 'getGJUsers20.php', skipRequest ? {} : req.gdParams({ str: username }), function (err1, res1, b1) { let searchResult = foundID ? foundID[0] : (accountMode || err1 || b1 == '-1' || b1.startsWith(" { let regex = new RegExp(`\\[\\[${x.toUpperCase()}\\]\\]`, "g") html = html.replace(regex, app.clean(userData[x])) }) return res.send(html) }) }) }) }