From f2a5ab90740abc0d2a3e1328407ac7ec6153985c Mon Sep 17 00:00:00 2001 From: callumok2004 Date: Mon, 21 Jun 2021 03:56:13 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=8C=9F=20Code=20Cleanup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/_app.tsx | 2 +- src/renderCard.tsx | 204 ++++++++++++++++++++------------------------- src/toBase64.ts | 12 ++- 3 files changed, 103 insertions(+), 115 deletions(-) diff --git a/pages/_app.tsx b/pages/_app.tsx index 6af3199..ab0b18c 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -1,5 +1,5 @@ import type { AppProps } from 'next/app' -export default function LandyardReadMe({ Component, pageProps }: AppProps) { +export default function LanyardReadMe({ Component, pageProps }: AppProps) { return } diff --git a/src/renderCard.tsx b/src/renderCard.tsx index a4b0573..b6ace86 100644 --- a/src/renderCard.tsx +++ b/src/renderCard.tsx @@ -116,32 +116,28 @@ const renderCard = async (body: LanyardTypes.Root, params: Parameters): Promise< transform: translate(0, -50%); height: 25px; "> -

- ${body.data.discord_user.username}${discrim !== 'hide' ? - `#${body.data.discord_user.discriminator}` - : ''} + ${body.data.discord_user.username}${discrim !== 'hide' ? ` + #${body.data.discord_user.discriminator}` : ''}

${flags.map((v) => { - return ( - `` + return (` + ` ) }).join('') } - - ${userStatus.length > 0 && hideStatus !== "true" ? `

- ${body.data.activities[0].emoji && body.data.activities[0].emoji.id ? - `` + ${body.data.activities[0].emoji && body.data.activities[0].emoji.id ? ` + ` : ``} - ${body.data.activities[0].emoji && !body.data.activities[0].emoji.id ? + ${body.data.activities[0].emoji && !body.data.activities[0].emoji.id ? body.data.activities[0].emoji.name + ' ' + userStatus : userStatus } - -

` - : ``} + ` : ``} - ${activity ? - - ` + ${activity ? `
- ${activity.assets && activity.assets.large_image ? - ` + ${activity.assets && activity.assets.large_image ? ` - ` - : ` + ` : ` `} - - ${activity.assets && activity.assets.small_image ? - `` - : ``} - + "/>`: ``}
${activity.name}

- ${activity.details ? - `

${activity.details}

` - : ``} - + ">${activity.details}

` : ``}
- ` + `: ``} - : ``} + ${body.data.listening_to_spotify === true && body.data.activities[Object.keys(body.data.activities).length - 1].type === 2 ? ` +
+ - ${body.data.listening_to_spotify === true && body.data.activities[Object.keys(body.data.activities).length - 1].type === 2 ? - - ` -
- - -
-

LISTENING NOW...

-

${body.data.spotify.song.replace(/\&/g, "and")}

-

By ${body.data.spotify.artist.replace(/\;/g, ",").replace(/\&/g, "and")}

-
-
- ` - - : ``} - - ${!activity && body.data.listening_to_spotify === false ? +
+

LISTENING NOW...

+

${body.data.spotify.song.replace(/\&/g, "and")}

+

By ${body.data.spotify.artist.replace(/\;/g, ",").replace(/\&/g, "and")}

+
+
+ ` : ``} + ${!activity && body.data.listening_to_spotify === false ? `
-

- I'm not currently doing anything! -

-
` + display: flex; + flex-direction: row; + height: 150px; + justify-content: center; + align-items: center; + "> +

+ I'm not currently doing anything! +

+ ` : ``} diff --git a/src/toBase64.ts b/src/toBase64.ts index 94c9b96..cf7d98c 100644 --- a/src/toBase64.ts +++ b/src/toBase64.ts @@ -1,3 +1,13 @@ import imageToBase64 from "image-to-base64"; -export const encodeBase64 = async (url: string): Promise => await imageToBase64(url); \ No newline at end of file +export const encodeBase64 = async (url: string): Promise => { + let response = ""; + + try { + response = await imageToBase64(url); + } catch (e) { + console.log(e) + } + + return response; +} \ No newline at end of file