diff --git a/index.js b/index.js index df70e45..b52441e 100644 --- a/index.js +++ b/index.js @@ -34,11 +34,12 @@ app.listen(PORT, () => { app.get('/embedCard', async (req, res) => { var discID = req.query.discordid + var server = 'https://' + (req.query.server || 'api.lanyard.rest') res.header("Content-Type", "text/html") var html = fs.readFileSync(path.join(__dirname, 'resources/embedCard.html')).toString() - var result = (await fetch(`https://api.lanyard.rest/v1/users/${discID}`).then(response => response.json())).data + var result = (await fetch(`${server}/v1/users/${discID}`).then(response => response.json())).data var user = result.discord_user @@ -75,11 +76,23 @@ app.get('/embedCard', async (req, res) => { app.get('/getUser', async (req, res) => { var discID = req.query.discordid + var server = 'https://' + (req.query.server || 'api.lanyard.rest') res.header("Content-Type", "text/html") var html = fs.readFileSync(path.join(__dirname, 'resources/userPage.html')).toString() - var data = (await fetch(`https://api.lanyard.rest/v1/users/${discID}`).then(response => response.json())) + try { + var data = (await fetch(`${server}/v1/users/${discID}`).then(response => response.json())) + } catch (error) { + res.send(` + +
Code: ${error}
+ Try clearing cache and trying again.
+
{USERNAME}
-Code to embed:
<iframe style="width: 90%; max-width: 750px; height: 300px;" src="{BASE_LINK}embedCard?discordid={DISCORD_ID}"></iframe>
Code to embed:
<iframe style="width: 90%; max-width: 750px; height: 300px;" src="{BASE_LINK}embedCard?discordid={DISCORD_ID}"></iframe>