delete: old next.js file
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"extends": ["next", "next/core-web-vitals"],
|
||||
"rules": {
|
||||
"react/no-unescaped-entities": "off",
|
||||
"@next/next/no-img-element": "off"
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"quoteProps": "consistent",
|
||||
"printWidth": 120,
|
||||
"bracketSpacing": true,
|
||||
"singleQuote": false,
|
||||
"useTabs": false,
|
||||
"arrowParens": "avoid",
|
||||
"tabWidth": 4
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
module.exports = {
|
||||
reactStrictMode: true
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
{
|
||||
"name": "next-app",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
"build": "next build",
|
||||
"start": "next start",
|
||||
"lint": "next lint"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/escape-html": "^1.0.1",
|
||||
"@types/ioredis": "^4.28.8",
|
||||
"@types/styled-components": "^5.1.10",
|
||||
"axios": "^0.21.1",
|
||||
"escape-html": "^1.0.3",
|
||||
"framer-motion": "^4.1.17",
|
||||
"image-to-base64": "^2.2.0",
|
||||
"ioredis": "^4.28.5",
|
||||
"next": "14.2.15",
|
||||
"react": "18.3.1",
|
||||
"react-dom": "18.3.1",
|
||||
"styled-components": "^5.3.0",
|
||||
"use-smooth-count": "^0.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/escape-html": "^1.0.1",
|
||||
"@types/image-to-base64": "^2.1.0",
|
||||
"@types/react": "^18.2.45",
|
||||
"eslint": "7.28.0",
|
||||
"eslint-config-next": "^14.2.15",
|
||||
"prettier": "^2.3.1",
|
||||
"typescript": "5.6.3"
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
import type { AppProps } from "next/app";
|
||||
import Head from "next/head";
|
||||
|
||||
export default function LanyardReadMe({ Component, pageProps }: AppProps) {
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="/favicon/apple-touch-icon.png" />
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="/favicon/favicon-32x32.png" />
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="/favicon/favicon-16x16.png" />
|
||||
<link rel="mask-icon" href="/favicon/safari-pinned-tab.svg" color="#5bbad5" />
|
||||
<meta name="msapplication-TileColor" content="#191d28" />
|
||||
<meta name="theme-color" content="#191d28" />
|
||||
</Head>
|
||||
<Component {...pageProps} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
import Document from "next/document";
|
||||
import { ServerStyleSheet } from "styled-components";
|
||||
|
||||
export default class MyDocument extends Document {
|
||||
static async getInitialProps(ctx: any) {
|
||||
const sheet = new ServerStyleSheet(),
|
||||
originalRenderPage = ctx.renderPage;
|
||||
|
||||
try {
|
||||
ctx.renderPage = () =>
|
||||
originalRenderPage({
|
||||
enhanceApp: (App: any) => (props: any) => sheet.collectStyles(<App {...props} />),
|
||||
});
|
||||
|
||||
const initialProps = await Document.getInitialProps(ctx);
|
||||
return {
|
||||
...initialProps,
|
||||
styles: (
|
||||
<>
|
||||
{initialProps.styles}
|
||||
{sheet.getStyleElement()}
|
||||
</>
|
||||
),
|
||||
};
|
||||
} finally {
|
||||
sheet.seal();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
import type { NextApiRequest, NextApiResponse } from "next";
|
||||
import renderCard from "../../src/renderCard";
|
||||
import { isSnowflake } from "../../src/snowflake";
|
||||
import redis from "../../src/redis";
|
||||
|
||||
type Data = {
|
||||
id?: string | string[];
|
||||
error?: any;
|
||||
code?: string;
|
||||
};
|
||||
|
||||
type Parameters = {
|
||||
theme?: string;
|
||||
bg?: string;
|
||||
hideStatus?: string;
|
||||
hideTimestamp?: string;
|
||||
hideDiscrim?: string;
|
||||
borderRadius?: string;
|
||||
animated?: string;
|
||||
};
|
||||
|
||||
export default async function handler(req: NextApiRequest, res: NextApiResponse<Data>) {
|
||||
let getUser: any = {};
|
||||
|
||||
if (!req.query.id)
|
||||
return res.send({
|
||||
error: `No ID provided.`,
|
||||
});
|
||||
|
||||
const params: Parameters = req.query,
|
||||
userId = req.query.id[0];
|
||||
|
||||
if (!isSnowflake(userId))
|
||||
return res.send({
|
||||
error: `That is not a valid snowflake ID!`,
|
||||
});
|
||||
|
||||
try {
|
||||
getUser.data = await fetch(`https://api.lanyard.rest/v1/users/${userId}`).then(res => res.json());
|
||||
} catch (error: any) {
|
||||
if (error.response.data && error.response.data.error.message)
|
||||
return res
|
||||
.status(404)
|
||||
.send({ error: error.response.data.error.message, code: error.response.data.error.code });
|
||||
|
||||
if (error.response.status === 404) return res.status(404).send({ error: "Invalid user!" });
|
||||
|
||||
console.log(error); // Only console log the error if its not a 404
|
||||
|
||||
return res.status(400).send({
|
||||
error: `Something went wrong! If everything looks correct and this still occurs, please contact @notcnrad on Twitter.`,
|
||||
});
|
||||
}
|
||||
|
||||
try {
|
||||
let user = await redis.hget("users", userId);
|
||||
if (!user) await redis.hset("users", userId, "true");
|
||||
} catch {
|
||||
null;
|
||||
}
|
||||
|
||||
res.setHeader("Content-Type", "image/svg+xml; charset=utf-8");
|
||||
res.setHeader("content-security-policy", "default-src 'none'; img-src * data:; style-src 'unsafe-inline'");
|
||||
|
||||
const svg = await renderCard(getUser.data, params);
|
||||
res.status(200).send(svg as any);
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
import type { NextApiRequest, NextApiResponse } from "next";
|
||||
import redis from "../../src/redis";
|
||||
|
||||
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
let users = await redis.hgetall("users");
|
||||
let count = Object.keys(users);
|
||||
|
||||
res.status(200).send({ count: count.length });
|
||||
}
|
||||
@@ -1,264 +0,0 @@
|
||||
import Head from "next/head";
|
||||
import styled, { createGlobalStyle } from "styled-components";
|
||||
import { useState, useEffect, useRef } from "react";
|
||||
import axios from "axios";
|
||||
import { useSmoothCount } from "use-smooth-count";
|
||||
|
||||
export default function Home({ userCount }: { userCount: number }) {
|
||||
const [userId, setUserId] = useState<null | string>(null);
|
||||
const [userError, setUserError] = useState<string>();
|
||||
const [copyState, setCopyState] = useState("Copy");
|
||||
|
||||
const countRef = useRef<HTMLDivElement | null>(null);
|
||||
const counter = useSmoothCount({ ref: countRef, target: userCount, duration: 3, curve: [0, 1, 0, 1] });
|
||||
|
||||
const copy = () => {
|
||||
navigator.clipboard.writeText(
|
||||
`[](https://discord.com/users/${userId})`
|
||||
);
|
||||
setCopyState("Copied!");
|
||||
|
||||
setTimeout(() => setCopyState("Copy"), 1500);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
try {
|
||||
await axios.get(`/api/${userId}`);
|
||||
setUserError(undefined);
|
||||
} catch (error: any) {
|
||||
console.log(error.response);
|
||||
if (error.response.status === 404 && error.response.data.code == "user_not_monitored")
|
||||
setUserError(`User not monitored by Lanyard, click to join the discord`);
|
||||
}
|
||||
})();
|
||||
}, [userId]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<GlobalStyle />
|
||||
<Head>
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" />
|
||||
<link
|
||||
href="https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;1,200;1,300;1,400&display=swap"
|
||||
rel="stylesheet"
|
||||
/>
|
||||
<title>Lanyard for GitHub Profile</title>
|
||||
<meta property="og:title" content="Lanyard for GitHub Profile" key="title" />
|
||||
<meta
|
||||
name="description"
|
||||
content="Utilize Lanyard to display your Discord Presence in your GitHub Profile"
|
||||
/>
|
||||
<meta
|
||||
name="og:description"
|
||||
content="Utilize Lanyard to display your Discord Presence in your GitHub Profile"
|
||||
/>
|
||||
</Head>
|
||||
<Main>
|
||||
<Container>
|
||||
<Title>lanyard profile readme 🏷️</Title>
|
||||
<Paragraph>Utilize Lanyard to display your Discord Presence in your GitHub Profile</Paragraph>
|
||||
<br />
|
||||
<Input onChange={el => setUserId(el.target.value)} placeholder="Enter your Discord ID" />
|
||||
{userId ? (
|
||||
<>
|
||||
<Output>
|
||||
[](https://discord.com/users/{userId})
|
||||
</Output>
|
||||
<ActionButton onClick={copy}>{copyState}</ActionButton>
|
||||
<a
|
||||
href="https://github.com/cnrad/lanyard-profile-readme#options"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
<ActionButton>Options</ActionButton>
|
||||
</a>
|
||||
<a
|
||||
style={{ textDecoration: "none" }}
|
||||
target="_blank"
|
||||
href={userError && "https://discord.gg/lanyard"}
|
||||
rel="noreferrer"
|
||||
>
|
||||
<Example
|
||||
src={`/api/${userId}`}
|
||||
alt={`${userError || "Please provide a valid user ID!"}`}
|
||||
style={{ color: "#ff8787" }}
|
||||
/>
|
||||
</a>
|
||||
</>
|
||||
) : null}
|
||||
</Container>
|
||||
</Main>
|
||||
<FooterStat>
|
||||
Lanyard Profile Readme has <div style={{ fontWeight: "bold", width: "3.2rem" }} ref={countRef} /> total
|
||||
users!
|
||||
</FooterStat>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export async function getServerSideProps(ctx: any) {
|
||||
let userCount = await axios
|
||||
.get("https://lanyard.cnrad.dev/api/getUserCount", { timeout: 1000 })
|
||||
.then(res => res.data.count)
|
||||
.catch(() => 1000);
|
||||
|
||||
return {
|
||||
props: { userCount },
|
||||
};
|
||||
}
|
||||
|
||||
const GlobalStyle = createGlobalStyle`
|
||||
*, *::before, *::after {
|
||||
box-sizing: border-box;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-family: 'Poppins', sans-serif;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar {
|
||||
width: 10px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: rgb(64 68 78);
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-track {
|
||||
background: rgb(24 28 39);
|
||||
}
|
||||
`;
|
||||
|
||||
const Main = styled.div`
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: start;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
max-width: 100vw;
|
||||
min-height: 100vh;
|
||||
background: #010103;
|
||||
background-size: cover;
|
||||
`;
|
||||
|
||||
const Container = styled.div`
|
||||
border-radius: 7px;
|
||||
margin-top: 60px;
|
||||
width: 80%;
|
||||
max-width: 450px;
|
||||
`;
|
||||
|
||||
const Title = styled.h1`
|
||||
text-align: left;
|
||||
font-size: 2rem;
|
||||
font-weight: 600;
|
||||
margin: 5px 0;
|
||||
color: #cecece;
|
||||
`;
|
||||
|
||||
const Paragraph = styled.p`
|
||||
color: #aaabaf;
|
||||
font-size: 1rem;
|
||||
`;
|
||||
|
||||
const Input = styled.input`
|
||||
text-align: left;
|
||||
border-radius: 8px;
|
||||
border: none;
|
||||
width: 100%;
|
||||
font-size: 0.9rem;
|
||||
padding: 0.45rem 0.75rem;
|
||||
color: #aaabaf;
|
||||
border: solid 1px rgba(255, 255, 255, 0.2);
|
||||
background: #000;
|
||||
box-shadow: 0px 3px 15px rgba(0, 0, 0, 0.2);
|
||||
transition: all ease-in-out 0.1s;
|
||||
|
||||
&:focus {
|
||||
outline: 0;
|
||||
border-color: rgba(255, 255, 255, 0.5);
|
||||
}
|
||||
`;
|
||||
|
||||
const Output = styled.div`
|
||||
margin: 15px 0;
|
||||
color: #aaabaf;
|
||||
word-break: break-word;
|
||||
border-radius: 8px;
|
||||
border: solid 1px #333;
|
||||
padding: 8px;
|
||||
background: #000;
|
||||
box-shadow: 0px 3px 15px rgba(0, 0, 0, 0.2);
|
||||
font-family: Monospace, sans-serif;
|
||||
`;
|
||||
|
||||
const ActionButton = styled.button`
|
||||
font-size: 0.9rem;
|
||||
padding: 5px 25px;
|
||||
margin-right: 10px;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
color: #888;
|
||||
border: solid 1px #333;
|
||||
background: transparent;
|
||||
transition: all ease-in-out 0.1s;
|
||||
|
||||
&:hover {
|
||||
color: #e6e6e6;
|
||||
border-color: #e6e6e6;
|
||||
}
|
||||
&:active {
|
||||
color: #fff;
|
||||
border-color: #fff;
|
||||
}
|
||||
`;
|
||||
|
||||
const Example = styled.img`
|
||||
display: block;
|
||||
margin: 30px auto 0px;
|
||||
max-width: 100%;
|
||||
`;
|
||||
|
||||
const FooterStat = styled.div`
|
||||
position: absolute;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
line-height: 1rem;
|
||||
bottom: 1rem;
|
||||
left: 50%;
|
||||
transform: translate(-50%, 0);
|
||||
background: #000;
|
||||
padding: 1rem 1.25rem;
|
||||
color: #fff;
|
||||
border-radius: 0.55rem;
|
||||
text-align: center;
|
||||
box-shadow: 0 2px 15px -10px #a21caf;
|
||||
min-width: 400px;
|
||||
|
||||
@media (max-width: 400px) {
|
||||
font-size: 14px;
|
||||
min-width: 365px;
|
||||
padding: 0.75rem 1rem;
|
||||
}
|
||||
|
||||
&:before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
border-radius: 0.55rem;
|
||||
border: 2px solid transparent;
|
||||
background: linear-gradient(45deg, #be123c, #6b21a8, #3730a3) border-box;
|
||||
-webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
|
||||
-webkit-mask-composite: xor;
|
||||
mask-composite: exclude;
|
||||
}
|
||||
`;
|
||||
|
Before Width: | Height: | Size: 9.0 KiB |
|
Before Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 5.2 KiB |
|
Before Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 4.1 KiB |
|
Before Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 3.4 KiB |
|
Before Width: | Height: | Size: 4.6 KiB |
|
Before Width: | Height: | Size: 4.3 KiB |
|
Before Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 3.2 KiB |
|
Before Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 5.2 KiB |
|
Before Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 4.8 KiB |
|
Before Width: | Height: | Size: 799 B |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 3.9 KiB |
|
Before Width: | Height: | Size: 3.9 KiB |
|
Before Width: | Height: | Size: 4.3 KiB |
|
Before Width: | Height: | Size: 8.3 KiB |
|
Before Width: | Height: | Size: 2.1 KiB |
@@ -1,26 +0,0 @@
|
||||
<?xml version="1.0" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
|
||||
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
|
||||
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
|
||||
width="700.000000pt" height="700.000000pt" viewBox="0 0 700.000000 700.000000"
|
||||
preserveAspectRatio="xMidYMid meet">
|
||||
<metadata>
|
||||
Created by potrace 1.14, written by Peter Selinger 2001-2017
|
||||
</metadata>
|
||||
<g transform="translate(0.000000,700.000000) scale(0.100000,-0.100000)"
|
||||
fill="#000000" stroke="none">
|
||||
<path d="M3087 6923 c-19 -8 -213 -195 -472 -453 l-440 -440 -670 -3 c-369 -2
|
||||
-681 -7 -695 -10 -14 -4 -38 -10 -55 -13 -64 -14 -157 -65 -211 -116 -55 -52
|
||||
-112 -147 -128 -213 -5 -16 -11 -39 -14 -50 -4 -11 -8 -519 -9 -1128 -4 -1222
|
||||
-5 -1207 57 -1334 37 -75 -24 -12 1017 -1060 2095 -2111 1967 -1985 2063
|
||||
-2031 112 -54 192 -72 305 -67 50 2 106 6 125 10 61 12 167 61 232 108 95 68
|
||||
2085 2071 2127 2141 36 60 76 153 86 201 16 75 13 230 -6 303 -42 157 -91 227
|
||||
-315 447 -89 88 -346 340 -569 560 -224 220 -495 487 -603 594 -108 106 -401
|
||||
394 -651 640 -973 958 -934 920 -987 947 -42 22 -120 50 -169 59 -25 5 -257
|
||||
15 -355 15 -20 0 29 54 277 303 165 166 307 316 315 332 33 69 13 170 -43 222
|
||||
-55 51 -141 65 -212 36z m-1703 -1686 c-44 -48 -59 -84 -58 -144 1 -62 16 -97
|
||||
61 -139 82 -77 186 -70 281 19 l55 52 -6 -62 c-12 -138 -115 -245 -256 -266
|
||||
-50 -7 -133 14 -185 47 -178 114 -175 375 5 488 28 18 121 48 128 42 3 -3 -9
|
||||
-19 -25 -37z"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 1.4 KiB |
@@ -1,4 +0,0 @@
|
||||
<svg width="283" height="64" viewBox="0 0 283 64" fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M141.04 16c-11.04 0-19 7.2-19 18s8.96 18 20 18c6.67 0 12.55-2.64 16.19-7.09l-7.65-4.42c-2.02 2.21-5.09 3.5-8.54 3.5-4.79 0-8.86-2.5-10.37-6.5h28.02c.22-1.12.35-2.28.35-3.5 0-10.79-7.96-17.99-19-17.99zm-9.46 14.5c1.25-3.99 4.67-6.5 9.45-6.5 4.79 0 8.21 2.51 9.45 6.5h-18.9zM248.72 16c-11.04 0-19 7.2-19 18s8.96 18 20 18c6.67 0 12.55-2.64 16.19-7.09l-7.65-4.42c-2.02 2.21-5.09 3.5-8.54 3.5-4.79 0-8.86-2.5-10.37-6.5h28.02c.22-1.12.35-2.28.35-3.5 0-10.79-7.96-17.99-19-17.99zm-9.45 14.5c1.25-3.99 4.67-6.5 9.45-6.5 4.79 0 8.21 2.51 9.45 6.5h-18.9zM200.24 34c0 6 3.92 10 10 10 4.12 0 7.21-1.87 8.8-4.92l7.68 4.43c-3.18 5.3-9.14 8.49-16.48 8.49-11.05 0-19-7.2-19-18s7.96-18 19-18c7.34 0 13.29 3.19 16.48 8.49l-7.68 4.43c-1.59-3.05-4.68-4.92-8.8-4.92-6.07 0-10 4-10 10zm82.48-29v46h-9V5h9zM36.95 0L73.9 64H0L36.95 0zm92.38 5l-27.71 48L73.91 5H84.3l17.32 30 17.32-30h10.39zm58.91 12v9.69c-1-.29-2.06-.49-3.2-.49-5.81 0-10 4-10 10V51h-9V17h9v9.2c0-5.08 5.91-9.2 13.2-9.2z" fill="#000"/>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 1.1 KiB |
@@ -1,95 +0,0 @@
|
||||
//thanks alistair @ uwu.red
|
||||
|
||||
export interface Root {
|
||||
success: boolean;
|
||||
data: Data;
|
||||
}
|
||||
|
||||
export interface Data {
|
||||
spotify: Spotify;
|
||||
listening_to_spotify: boolean;
|
||||
discord_user: DiscordUser;
|
||||
discord_status: string;
|
||||
activities: Activity[];
|
||||
active_on_discord_mobile: boolean;
|
||||
active_on_discord_desktop: boolean;
|
||||
}
|
||||
|
||||
export interface Spotify {
|
||||
track_id: string;
|
||||
timestamps: Timestamps;
|
||||
song: string;
|
||||
artist: string;
|
||||
album_art_url: string;
|
||||
album: string;
|
||||
}
|
||||
|
||||
export interface Timestamps {
|
||||
start: number;
|
||||
end: number;
|
||||
}
|
||||
|
||||
export interface DiscordUser {
|
||||
username: string;
|
||||
public_flags: number;
|
||||
id: string;
|
||||
discriminator: string;
|
||||
avatar: string;
|
||||
global_name: string;
|
||||
display_name: string;
|
||||
clan: ClanTag | null;
|
||||
avatar_decoration_data: AvatarDecoration | null;
|
||||
}
|
||||
|
||||
export interface ClanTag {
|
||||
tag: string;
|
||||
badge: string;
|
||||
identity_enabled: boolean;
|
||||
identity_guild_id: number;
|
||||
}
|
||||
|
||||
export interface AvatarDecoration {
|
||||
sku_id: string;
|
||||
asset: string;
|
||||
expires_at: number;
|
||||
}
|
||||
|
||||
export interface Activity {
|
||||
type: number;
|
||||
state: string;
|
||||
name: string;
|
||||
id: string;
|
||||
emoji?: Emoji;
|
||||
created_at: number;
|
||||
application_id?: string;
|
||||
timestamps?: Timestamps2;
|
||||
sync_id?: string;
|
||||
session_id?: string;
|
||||
party?: Party;
|
||||
flags?: number;
|
||||
details?: string;
|
||||
assets?: Assets;
|
||||
buttons?: string[];
|
||||
}
|
||||
|
||||
export interface Emoji {
|
||||
name: string;
|
||||
id: number;
|
||||
animated: boolean;
|
||||
}
|
||||
|
||||
export interface Timestamps2 {
|
||||
start: number;
|
||||
end?: number;
|
||||
}
|
||||
|
||||
export interface Party {
|
||||
id: string;
|
||||
}
|
||||
|
||||
export interface Assets {
|
||||
small_text?: string;
|
||||
small_image?: string;
|
||||
large_text: string;
|
||||
large_image: string;
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
export const getFlags = (flag: number): string[] => {
|
||||
let flags: string[] = [];
|
||||
|
||||
// In the order they appear on profiles
|
||||
if (flag & 1) flags.push("Discord_Employee"); // 1 << 0
|
||||
if (flag & 262144) flags.push("Discord_Certified_Moderator"); // 1 << 18
|
||||
if (flag & 2) flags.push("Partnered_Server_Owner"); // 1 << 1
|
||||
if (flag & 4) flags.push("HypeSquad_Events"); // 1 << 2
|
||||
if (flag & 64) flags.push("House_Bravery"); // 1 << 6
|
||||
if (flag & 128) flags.push("House_Brilliance"); // 1 << 7
|
||||
if (flag & 256) flags.push("House_Balance"); // 1 << 8
|
||||
if (flag & 8) flags.push("Bug_Hunter_Level_1"); // 1 << 3
|
||||
if (flag & 16384) flags.push("Bug_Hunter_Level_2"); // 1 << 14
|
||||
if (flag & 4194304) flags.push("Active_Developer"); // 1 << 22
|
||||
if (flag & 131072) flags.push("Early_Verified_Bot_Developer"); // 1 << 17
|
||||
if (flag & 512) flags.push("Early_Supporter"); // 1 << 9
|
||||
|
||||
return flags;
|
||||
};
|
||||
@@ -1,9 +0,0 @@
|
||||
import Redis from "ioredis";
|
||||
|
||||
const redis = new Redis(process.env.REDIS_URL, {
|
||||
connectTimeout: 1000,
|
||||
lazyConnect: false,
|
||||
maxRetriesPerRequest: 1,
|
||||
});
|
||||
|
||||
export default redis;
|
||||
@@ -1,578 +0,0 @@
|
||||
// probably the messiest code i've ever written but it works so :)
|
||||
|
||||
import { Badges } from "../public/assets/badges/BadgesEncoded";
|
||||
import { getFlags } from "./getFlags";
|
||||
import * as LanyardTypes from "./LanyardTypes";
|
||||
import { encodeBase64 } from "./toBase64";
|
||||
import escape from "escape-html";
|
||||
|
||||
type Parameters = {
|
||||
theme?: string;
|
||||
bg?: string;
|
||||
clanbg?: string;
|
||||
animated?: string;
|
||||
animatedDecoration?: string;
|
||||
hideDiscrim?: string;
|
||||
hideStatus?: string;
|
||||
hideTimestamp?: string;
|
||||
hideBadges?: string;
|
||||
hideProfile?: string;
|
||||
hideActivity?: string;
|
||||
hideSpotify?: string;
|
||||
hideClan?: string;
|
||||
hideDecoration?: string;
|
||||
ignoreAppId?: string;
|
||||
showDisplayName?: string;
|
||||
borderRadius?: string;
|
||||
idleMessage?: string;
|
||||
};
|
||||
|
||||
const parseBool = (string: string | undefined): boolean => string === "true" ? true : false;
|
||||
|
||||
const parseAppId = (string: string | undefined): Array<string> => {
|
||||
if (string === undefined) return [];
|
||||
return string.split(",");
|
||||
}
|
||||
|
||||
const elapsedTime = (timestamp: any) => {
|
||||
let startTime = timestamp;
|
||||
let endTime = Number(new Date());
|
||||
let difference = (endTime - startTime) / 1000;
|
||||
|
||||
// we only calculate them, but we don't display them.
|
||||
// this fixes a bug in the Discord API that does not send the correct timestamp to presence.
|
||||
let daysDifference = Math.floor(difference / 60 / 60 / 24);
|
||||
difference -= daysDifference * 60 * 60 * 24;
|
||||
|
||||
let hoursDifference = Math.floor(difference / 60 / 60);
|
||||
difference -= hoursDifference * 60 * 60;
|
||||
|
||||
let minutesDifference = Math.floor(difference / 60);
|
||||
difference -= minutesDifference * 60;
|
||||
|
||||
let secondsDifference = Math.floor(difference);
|
||||
|
||||
return `${hoursDifference >= 1 ? ("0" + hoursDifference).slice(-2) + ":" : ""}${("0" + minutesDifference).slice(
|
||||
-2
|
||||
)}:${("0" + secondsDifference).slice(-2)}`;
|
||||
};
|
||||
|
||||
const renderCard = async (body: LanyardTypes.Root, params: Parameters): Promise<string> => {
|
||||
let { data } = body;
|
||||
|
||||
let avatarBorderColor: string = "#747F8D",
|
||||
avatarExtension: string = "webp",
|
||||
statusExtension: string = "webp",
|
||||
activity: any = false,
|
||||
backgroundColor: string = "1a1c1f",
|
||||
theme = "dark",
|
||||
borderRadius = "10px",
|
||||
idleMessage = "I'm not currently doing anything!";
|
||||
|
||||
let hideStatus = parseBool(params.hideStatus);
|
||||
let hideTimestamp = parseBool(params.hideTimestamp);
|
||||
let hideBadges = parseBool(params.hideBadges);
|
||||
let hideProfile = parseBool(params.hideProfile);
|
||||
let hideActivity = params.hideActivity ?? "false";
|
||||
let hideSpotify = parseBool(params.hideSpotify);
|
||||
let hideClan = parseBool(params.hideClan);
|
||||
let hideDecoration = parseBool(params.hideDecoration);
|
||||
let ignoreAppId = parseAppId(params.ignoreAppId);
|
||||
let hideDiscrim = parseBool(params.hideDiscrim);
|
||||
let showDisplayName = parseBool(params.showDisplayName);
|
||||
|
||||
if (!data.discord_user.avatar_decoration_data) hideDecoration = true;
|
||||
if (parseBool(params.hideDiscrim) || body.data.discord_user.discriminator === "0") hideDiscrim = true;
|
||||
if (!body.data.discord_user.clan) hideClan = true;
|
||||
if (data.activities[0]?.emoji?.animated) statusExtension = "gif";
|
||||
if (data.discord_user.avatar && data.discord_user.avatar.startsWith("a_")) avatarExtension = "gif";
|
||||
if (params.animated === "false") avatarExtension = "webp";
|
||||
if (params.theme === "light") {
|
||||
backgroundColor = "#eee";
|
||||
theme = "light";
|
||||
}
|
||||
if (params.bg) backgroundColor = params.bg;
|
||||
let clanBackgroundColor: string = theme === "light" ? "#e0dede" : "#111214";
|
||||
if (params.clanbg) clanBackgroundColor = params.clanbg;
|
||||
if (params.idleMessage) idleMessage = params.idleMessage;
|
||||
if (params.borderRadius) borderRadius = params.borderRadius;
|
||||
|
||||
let avatar: string;
|
||||
if (data.discord_user.avatar) {
|
||||
avatar = await encodeBase64(
|
||||
`https://cdn.discordapp.com/avatars/${data.discord_user.id}/${
|
||||
data.discord_user.avatar
|
||||
}.${avatarExtension}?size=${avatarExtension === "gif" ? "64" : "256"}`
|
||||
);
|
||||
} else {
|
||||
avatar = await encodeBase64(
|
||||
`https://cdn.discordapp.com/embed/avatars/${data.discord_user.discriminator === "0"
|
||||
? ((Number(BigInt(data.discord_user.id) >> BigInt(22))) % 6)
|
||||
: Number(data.discord_user.discriminator) % 5}.png`
|
||||
);
|
||||
}
|
||||
|
||||
let clanBadge: string;
|
||||
if (data.discord_user.clan) {
|
||||
clanBadge = await encodeBase64(
|
||||
`https://cdn.discordapp.com/clan-badges/${data.discord_user.clan.identity_guild_id}/${data.discord_user.clan.badge}.png?size=16`
|
||||
);
|
||||
}
|
||||
|
||||
let avatarDecoration: string;
|
||||
if (data.discord_user.avatar_decoration_data) {
|
||||
avatarDecoration = await encodeBase64(
|
||||
`https://cdn.discordapp.com/avatar-decoration-presets/${data.discord_user.avatar_decoration_data.asset}.png?size=64&passthrough=${params.animatedDecoration || "true"}`
|
||||
);
|
||||
}
|
||||
|
||||
switch (data.discord_status) {
|
||||
case "online":
|
||||
avatarBorderColor = "#43B581";
|
||||
break;
|
||||
case "idle":
|
||||
avatarBorderColor = "#FAA61A";
|
||||
break;
|
||||
case "dnd":
|
||||
avatarBorderColor = "#F04747";
|
||||
break;
|
||||
case "offline":
|
||||
avatarBorderColor = "#747F8D";
|
||||
break;
|
||||
}
|
||||
|
||||
let flags: string[] = getFlags(data.discord_user.public_flags);
|
||||
if (data.discord_user.avatar && data.discord_user.avatar.includes("a_")) flags.push("Nitro");
|
||||
|
||||
let userStatus: Record<string, any> | null = null;
|
||||
if (data.activities[0] && data.activities[0].type === 4) userStatus = data.activities[0];
|
||||
|
||||
const activities = data.activities
|
||||
// Filter only type 0
|
||||
.filter(activity => activity.type === 0)
|
||||
// Filter ignored app ID
|
||||
.filter(activity => !ignoreAppId.includes(activity.application_id ?? ""));
|
||||
|
||||
// Take the highest one
|
||||
activity = Array.isArray(activities) ? activities[0] : activities;
|
||||
|
||||
// Calculate height of parent SVG element
|
||||
const svgHeight = (): string => {
|
||||
if (hideProfile) return "130";
|
||||
if (hideActivity === "true") return "91";
|
||||
if (hideActivity === "whenNotUsed" && !activity && !data.listening_to_spotify) return "91";
|
||||
if (hideSpotify && data.listening_to_spotify) return "210";
|
||||
return "210";
|
||||
}
|
||||
|
||||
// Calculate height of main div element
|
||||
const divHeight = (): string => {
|
||||
if (hideProfile) return "120";
|
||||
if (hideActivity === "true") return "81";
|
||||
if (hideActivity === "whenNotUsed" && !activity && !data.listening_to_spotify) return "81";
|
||||
if (hideSpotify && data.listening_to_spotify) return "200";
|
||||
return "200";
|
||||
}
|
||||
|
||||
return `
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xhtml="http://www.w3.org/1999/xhtml" width="410px" height="${svgHeight()}px">
|
||||
<defs>
|
||||
<style>
|
||||
.hover-opacity:hover {
|
||||
opacity: 0.25;
|
||||
}
|
||||
|
||||
.transition {
|
||||
transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter;
|
||||
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
||||
transition-duration: 200ms;
|
||||
}
|
||||
</style>
|
||||
</defs>
|
||||
<foreignObject x="0" y="0" width="410" height="${svgHeight()}">
|
||||
<div xmlns="http://www.w3.org/1999/xhtml" style="
|
||||
position: absolute;
|
||||
width: 400px;
|
||||
height: ${divHeight()}px;
|
||||
inset: 0;
|
||||
background-color: #${backgroundColor};
|
||||
color: ${theme === "dark" ? "#fff" : "#000"};
|
||||
font-family: 'Century Gothic', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
|
||||
font-size: 16px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 5px;
|
||||
border-radius: ${borderRadius};
|
||||
">
|
||||
|
||||
${
|
||||
hideProfile ? "" : `
|
||||
<div style="
|
||||
width: 400px;
|
||||
height: 100px;
|
||||
inset: 0;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
padding-bottom: 5px;
|
||||
${hideActivity !== "false" && !activity && !data.listening_to_spotify ?
|
||||
""
|
||||
: `border-bottom: solid 0.5px ${theme === "dark" ?
|
||||
"hsl(0, 0%, 100%, 10%)"
|
||||
: "hsl(0, 0%, 0%, 10%)"
|
||||
}`
|
||||
}
|
||||
">
|
||||
<div style="
|
||||
display: flex;
|
||||
position: relative;
|
||||
flex-direction: row;
|
||||
height: 80px;
|
||||
width: 80px;
|
||||
">
|
||||
<img src="data:image/png;base64,${avatar}"
|
||||
style="
|
||||
border-radius: 50%;
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
position: relative;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
"/>
|
||||
${hideDecoration || !data.discord_user.avatar_decoration_data ? "" : `
|
||||
<img src="data:image/png;base64,${avatarDecoration!}"
|
||||
class="hover-opacity transition"
|
||||
style="
|
||||
display: block;
|
||||
width: 64px;
|
||||
height: 64px;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
"/>
|
||||
`}
|
||||
<span style="
|
||||
position: absolute;
|
||||
bottom: 14px;
|
||||
right: 14px;
|
||||
height: 13px;
|
||||
width: 13px;
|
||||
background-color: ${avatarBorderColor};
|
||||
border-radius: 50%;
|
||||
border: 3px solid #${backgroundColor};
|
||||
" />
|
||||
</div>
|
||||
<div style="
|
||||
height: 80px;
|
||||
width: 260px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
">
|
||||
<div style="
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
height: 25px;
|
||||
">
|
||||
<h1 style="
|
||||
font-size: 1.15rem;
|
||||
margin: 0 12px 0 0;
|
||||
white-space: nowrap;
|
||||
">
|
||||
${escape(showDisplayName ? data.discord_user.global_name : data.discord_user.username)}${
|
||||
!hideDiscrim && !showDisplayName
|
||||
? `<span style="color: ${theme === "dark" ? "#ccc" : "#666"}; font-weight: lighter;">#${
|
||||
data.discord_user.discriminator
|
||||
}</span>`
|
||||
: ""
|
||||
}
|
||||
</h1>
|
||||
|
||||
${hideClan || !data.discord_user.clan?.tag && !data.discord_user.clan?.badge ? "" : `
|
||||
<span style="
|
||||
background-color: ${clanBackgroundColor};
|
||||
border-radius: 0.375rem;
|
||||
padding-left: 0.5rem;
|
||||
padding-right: 0.5rem;
|
||||
margin-left: -6px;
|
||||
margin-right: 12px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
font-size: 16px;
|
||||
font-weight: 500;
|
||||
height: 100%;
|
||||
">
|
||||
<img src="data:image/png;base64,${clanBadge!}" />
|
||||
<p style="margin-bottom: 1.1rem">${escape(data.discord_user.clan!.tag)}</p>
|
||||
</span>
|
||||
`}
|
||||
|
||||
${hideBadges ? "" : flags.map(v => `
|
||||
<img src="data:image/png;base64,${Badges[v]}" style="
|
||||
width: auto;
|
||||
height: 20px;
|
||||
position: relative;
|
||||
top: 50%;
|
||||
transform: translate(0%, -50%);
|
||||
margin-right: 7px;
|
||||
" />`).join("")
|
||||
}
|
||||
</div>
|
||||
${showDisplayName ?
|
||||
`<h2 style="
|
||||
font-size: 0.95rem;
|
||||
margin: 0;
|
||||
white-space: nowrap;
|
||||
font-weight: 400;
|
||||
">
|
||||
${escape(data.discord_user.username)}
|
||||
</h2>`
|
||||
: ``
|
||||
}
|
||||
${
|
||||
userStatus && !hideStatus ? `
|
||||
<p style="
|
||||
font-size: 0.9rem;
|
||||
margin: 0;
|
||||
color: ${theme === "dark" ? "#aaa" : "#333"};
|
||||
font-weight: 400;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
">
|
||||
${
|
||||
userStatus.emoji?.id ? `
|
||||
<img src="data:image/png;base64,${await encodeBase64(
|
||||
`https://cdn.discordapp.com/emojis/${userStatus.emoji.id}.${statusExtension}`
|
||||
)}"
|
||||
style="
|
||||
width: 15px;
|
||||
height: 15px;
|
||||
position: relative;
|
||||
top: 10px;
|
||||
transform: translate(0%, -50%);
|
||||
margin: 0 2px 0 0;
|
||||
" />` : ''
|
||||
}
|
||||
${
|
||||
userStatus.state && userStatus.emoji?.name && !userStatus.emoji.id
|
||||
? `${userStatus.emoji.name} ${escape(userStatus.state)}`
|
||||
: userStatus.state
|
||||
? escape(userStatus.state)
|
||||
: !userStatus.state && userStatus.emoji?.name && !userStatus.emoji.id
|
||||
? escape(userStatus.emoji.name)
|
||||
: ''
|
||||
}
|
||||
</p>` : ``
|
||||
}
|
||||
</div>
|
||||
</div>`
|
||||
}
|
||||
|
||||
${
|
||||
activity ? `
|
||||
<div style="
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
height: 120px;
|
||||
margin-left: 15px;
|
||||
font-size: 0.75rem;
|
||||
padding-top: 18px;
|
||||
">
|
||||
<div style="
|
||||
margin-right: 15px;
|
||||
width: auto;
|
||||
height: auto;
|
||||
">
|
||||
${
|
||||
activity.assets?.large_image ? `
|
||||
<img src="data:image/png;base64,${await encodeBase64(
|
||||
activity.assets.large_image.startsWith("mp:external/")
|
||||
? `https://media.discordapp.net/external/${activity.assets.large_image.replace("mp:external/", "")}`
|
||||
: `https://cdn.discordapp.com/app-assets/${activity.application_id}/${activity.assets.large_image}.webp`
|
||||
)}"
|
||||
style="
|
||||
width: 80px;
|
||||
height: 80px;
|
||||
border: solid 0.5px #222;
|
||||
border-radius: 10px;
|
||||
"/>
|
||||
` : `
|
||||
<img src="data:image/png;base64,${await encodeBase64(
|
||||
`https://lanyard-profile-readme.vercel.app/assets/unknown.png`
|
||||
)}" style="
|
||||
width: 70px;
|
||||
height: 70px;
|
||||
margin-top: 4px;
|
||||
filter: invert(100);
|
||||
"/>
|
||||
`}
|
||||
${
|
||||
activity.assets?.small_image ? `
|
||||
<img src="data:image/png;base64,${await encodeBase64(
|
||||
activity.assets.small_image.startsWith("mp:external/")
|
||||
? `https://media.discordapp.net/external/${activity.assets.small_image.replace("mp:external/", "")}`
|
||||
: `https://cdn.discordapp.com/app-assets/${activity.application_id}/${activity.assets.small_image}.webp`
|
||||
)}"
|
||||
style="
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
border-radius: 50%;
|
||||
margin-left: -26px;
|
||||
margin-bottom: -8px;
|
||||
"/>` : ``
|
||||
}
|
||||
</div>
|
||||
<div style="
|
||||
color: #999;
|
||||
margin-top: ${
|
||||
activity.timestamps?.start && !hideTimestamp
|
||||
? "-6px"
|
||||
: "5px"
|
||||
};
|
||||
line-height: 1;
|
||||
width: 279px;
|
||||
">
|
||||
<p style="
|
||||
color: ${theme === "dark" ? "#fff" : "#000"};
|
||||
font-size: 0.85rem;
|
||||
font-weight: bold;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
height: 15px;
|
||||
margin: 7px 0;
|
||||
">${escape(activity.name)}</p>
|
||||
${
|
||||
activity.details
|
||||
? `
|
||||
<p style="
|
||||
color: ${theme === "dark" ? "#ccc" : "#777"};
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
font-size: 0.85rem;
|
||||
text-overflow: ellipsis;
|
||||
height: 15px;
|
||||
margin: 7px 0;
|
||||
">${escape(activity.details)}</p>`
|
||||
: ``
|
||||
}
|
||||
${
|
||||
activity.state
|
||||
? `
|
||||
<p style="
|
||||
color: ${theme === "dark" ? "#ccc" : "#777"};
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
font-size: 0.85rem;
|
||||
text-overflow: ellipsis;
|
||||
height: 15px;
|
||||
margin: 7px 0;
|
||||
">${escape(activity.state)}${
|
||||
activity.party?.size
|
||||
? ` (${activity.party.size[0]} of ${activity.party.size[1]})`
|
||||
: ""
|
||||
}</p>` : ``
|
||||
}
|
||||
${
|
||||
activity.timestamps?.start && !hideTimestamp ? `
|
||||
<p style="
|
||||
color: ${theme === "dark" ? "#ccc" : "#777"};
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
font-size: 0.85rem;
|
||||
text-overflow: ellipsis;
|
||||
height: 15px;
|
||||
margin: 7px 0;
|
||||
">${elapsedTime(new Date(activity.timestamps.start).getTime())} elapsed</p>`
|
||||
: ``
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
` : ``
|
||||
}
|
||||
|
||||
${
|
||||
data.listening_to_spotify && !activity && !hideSpotify && data.activities[Object.keys(data.activities).length - 1].type === 2
|
||||
? `
|
||||
<div style="
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
height: 120px;
|
||||
margin-left: 15px;
|
||||
font-size: 0.8rem;
|
||||
padding-top: 18px;
|
||||
">
|
||||
<img src="${await (async () => {
|
||||
const album = await encodeBase64(data.spotify.album_art_url);
|
||||
if (album) return `data:image/png;base64,${album}" style="border: solid 0.5px #222;`;
|
||||
return 'https://lanyard-profile-readme.vercel.app/assets/unknown.png" style="filter: invert(100);';
|
||||
})()}
|
||||
width: 80px;
|
||||
height: 80px;
|
||||
border-radius: 10px;
|
||||
margin-right: 15px;
|
||||
"/>
|
||||
|
||||
<div style="
|
||||
color: #999;
|
||||
margin-top: -3px;
|
||||
line-height: 1;
|
||||
width: 279px;
|
||||
">
|
||||
<p style="font-size: 0.75rem; font-weight: bold; color: ${
|
||||
theme === "dark" ? "#1CB853" : "#0d943d"
|
||||
}; margin-bottom: 15px;">LISTENING TO SPOTIFY...</p>
|
||||
<p style="
|
||||
height: 15px;
|
||||
color: ${theme === "dark" ? "#fff" : "#000"};
|
||||
font-weight: bold;
|
||||
font-size: 0.85rem;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
margin: 7px 0;
|
||||
">${escape(data.spotify.song)}</p>
|
||||
<p style="
|
||||
margin: 7px 0;
|
||||
height: 15px;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
font-size: 0.85rem;
|
||||
text-overflow: ellipsis;
|
||||
color: ${theme === "dark" ? "#ccc" : "#777"};
|
||||
">By ${escape(data.spotify.artist)}</p>
|
||||
</div>
|
||||
</div>
|
||||
` : ``
|
||||
}
|
||||
${
|
||||
!activity && (!data.listening_to_spotify || hideSpotify) && hideActivity === "false"
|
||||
? `<div style="
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
height: 150px;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
">
|
||||
<p style="
|
||||
font-style: italic;
|
||||
font-size: 0.8rem;
|
||||
color: ${theme === "dark" ? "#aaa" : "#444"};
|
||||
height: auto;
|
||||
text-align: center;
|
||||
">
|
||||
${escape(idleMessage)}
|
||||
</p>
|
||||
</div>` : ``
|
||||
}
|
||||
|
||||
</div>
|
||||
</foreignObject>
|
||||
</svg>
|
||||
`;
|
||||
};
|
||||
|
||||
export default renderCard;
|
||||
@@ -1,9 +0,0 @@
|
||||
const EPOCH = 1420070400000; // Discord's EPOCH
|
||||
|
||||
// Snowflakes will never be a string
|
||||
export function isSnowflake(snowflake: number | string): boolean {
|
||||
snowflake = Number(snowflake);
|
||||
return (
|
||||
Number.isInteger(+snowflake) && snowflake > 4194304 && !isNaN(new Date(snowflake / 4194304 + EPOCH).getTime())
|
||||
);
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
import imageToBase64 from "image-to-base64";
|
||||
|
||||
export const encodeBase64 = async (url: string): Promise<string> => {
|
||||
let response = "";
|
||||
|
||||
try {
|
||||
response = await imageToBase64(url);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
|
||||
return response;
|
||||
};
|
||||
@@ -1,31 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"lib": [
|
||||
"dom",
|
||||
"dom.iterable",
|
||||
"esnext"
|
||||
],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"strict": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noEmit": true,
|
||||
"esModuleInterop": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"jsx": "preserve",
|
||||
"incremental": true
|
||||
},
|
||||
"include": [
|
||||
"next-env.d.ts",
|
||||
"**/*.ts",
|
||||
"**/*.tsx",
|
||||
"pages/_document.tsx"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
]
|
||||
}
|
||||