This commit is contained in:
Bingus_Violet 2024-01-07 02:23:18 -06:00
parent 73d4d1511e
commit a542a67e3b
4 changed files with 52 additions and 12 deletions

View file

@ -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(`
<link rel="stylesheet" href="./style.css">
<h1>Error!</h1>
<p>Code: ${error}<br>
Try clearing cache and trying again.
</p>
`)
return
}
var result = data.data
@ -102,7 +115,7 @@ app.get('/getUser', async (req, res) => {
"USERNAME": user.username,
"DISCORD_ID": user.id,
"STATUS": user.discord_status,
"BASE_LINK": "https://code-server-production-d69b.up.railway.app/proxy/8080/"
"BASE_LINK": "localhost:8080/"
}
if (user.discriminator != 0) {

View file

@ -15,6 +15,7 @@
<h1>{DISPLAY_NAME}</h1>
<p style="color: gray">{USERNAME}</p>
<iframe style="width: 90%; max-width: 750px; height: 300px; overflow: visible;" src="./embedCard?discordid={DISCORD_ID}"></iframe>
<p>Code to embed:<br> <span style="font-family: 'Source Code Pro'; background-color: rgb(40, 40, 50); display: block;">&lt;iframe style="width: 90%; max-width: 750px; height: 300px;" src="{BASE_LINK}embedCard?discordid={DISCORD_ID}"&gt;&lt;/iframe&gt;</p></span>
<p>Code to embed:<br> <span class="code">&lt;iframe style="width: 90%; max-width: 750px; height: 300px;" src="{BASE_LINK}embedCard?discordid={DISCORD_ID}"&gt;&lt;/iframe&gt;</p></span>
<a href="./blah">Customize Card</a>
</body>
</html>

View file

@ -11,11 +11,20 @@
</head>
<body>
<h1>Discord Embedder</h1>
<hr>
<form action="./getUser">
<input type="text" name="discordid" placeholder="Your Discord ID">
<label for="discordid">Discord ID:</label>
<input id="discordid" type="text" name="discordid" placeholder="Your Discord ID">
<br>
<label for="serverselect">Server:</label>
<select id="serverselect" name="server">
<option>api.lanyard.rest</option>
</select>
<br><br>
<input type="submit">
</form>
<p>You can get your Discord ID by:</p>
<p>Lorem ipsum dolor sit amet consectetur, adipisicing elit. Aspernatur odio dolores reiciendis recusandae ad explicabo repellendus possimus dignissimos quam quo necessitatibus error excepturi cumque sapiente quos, autem obcaecati quidem enim.</p>
<hr>
<h2>Usage</h2>
<p>To use Discord Embedder, first make sure you're in the corresponding Discord Server of one of our supported apis. Then, enable developer mode on discord, copy your ID, and paste it here! If you've set it all up correctly, you should be able to view your data!</p>
</body>
</html>

View file

@ -12,14 +12,31 @@ body, input {
}
input[type="text"] {
font-size: 1.5rem;
margin: 15vh auto;
padding: 15px;
width: 90%;
max-width: 500px;
}
input {
background-color: black;
border: 2px gray solid;
form {
margin: 10px;
}
input, select {
margin: 5px auto;
padding: 10px;
font-size: 1.25rem;
background-color: black;
color: white;
border: 2px gray solid;
border-radius: 10px;
}
label {
font-size: 1.5rem;
}
.code {
font-family: 'Source Code Pro';
background-color: rgb(40, 40, 50);
display: block;
padding: 10px;
}