const request = require('request') const fs = require('fs') const Level = require('../classes/Level.js') module.exports = async (app, req, res, api, ID, analyze) => { if (app.offline) { if (!api && levelID < 0) return res.redirect('/') if (!api) return res.redirect('search/' + req.params.id) else return res.send("-1") } let levelID = ID || req.params.id if (levelID == "daily") levelID = -1 else if (levelID == "weekly") levelID = -2 else levelID = levelID.replace(/[^0-9]/g, "") request.post(app.endpoint + 'downloadGJLevel22.php', { form: app.gdParams({ levelID }) }, async function (err, resp, body) { if (err || !body || body == '-1' || body.startsWith(" { let regex = new RegExp(`\\[\\[${x.toUpperCase()}\\]\\]`, "g") html = html.replace(regex, app.clean(level[x])) }) return res.send(html) }) } if (level.difficulty == "Extreme Demon") { request.get('https://www.pointercrate.com/api/v1/demons/?name=' + level.name.trim(), function (err, resp, demonList) { if (err) return sendLevel() let demon = JSON.parse(demonList) if (demon[0] && demon[0].position <= 150) level.demonList = demon[0].position return sendLevel() }) } else return sendLevel() }) }) }) }) }