diff --git a/src/lib/server/discord.js b/src/lib/server/discord.js index c2daa82..4c9ad17 100644 --- a/src/lib/server/discord.js +++ b/src/lib/server/discord.js @@ -1,11 +1,19 @@ import { DISCORD_TOKEN } from '$env/static/private'; import config from '$lib/config'; +/** @type {any} */ +let cache; + export default async function () { + if (cache) return cache; + const response = await fetch(`https://discord.com/api/users/${config.DISCORD}`, { method: 'GET', headers: { Authorization: `Bot ${DISCORD_TOKEN}` } }); - return response.json(); + const data = await response.json(); + cache = data; + + return data; } diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 8c9dee4..197d573 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -10,19 +10,10 @@ - + - + diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 99042f5..0586c80 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -89,6 +89,7 @@
+ diff --git a/src/routes/api/avatar/+server.js b/src/routes/api/avatar/+server.js new file mode 100644 index 0000000..afc976e --- /dev/null +++ b/src/routes/api/avatar/+server.js @@ -0,0 +1,11 @@ +import discord from '$lib/server/discord'; + +/** @type { import("./$types").RequestHandler } */ +export async function GET() { + const data = await discord(); + const response = await fetch( + `https://cdn.discordapp.com/avatars/${data.id}/${data.avatar}.png?size=256` + ); + + return new Response(await response.blob()); +} diff --git a/static/buttons/rovin.png b/static/buttons/rovin.png new file mode 100644 index 0000000..d533b67 Binary files /dev/null and b/static/buttons/rovin.png differ