forked from creations/profilePage
add option to use vibrant colors from avatar needs moving around
This commit is contained in:
parent
30e9057ba8
commit
ff0ece9626
8 changed files with 120 additions and 73 deletions
|
@ -1,3 +1,4 @@
|
|||
import { getImageColors } from "@/helpers/colors";
|
||||
import { lanyardConfig } from "@config/environment";
|
||||
import { renderEjsTemplate } from "@helpers/ejs";
|
||||
import { getLanyardData, handleReadMe } from "@helpers/lanyard";
|
||||
|
@ -37,6 +38,14 @@ async function handler(): Promise<Response> {
|
|||
status = presence.discord_status;
|
||||
}
|
||||
|
||||
let colors: ImageColorResult | null = null;
|
||||
if (presence.kv.colors === "true") {
|
||||
const avatar: string = presence.discord_user.avatar
|
||||
? `https://cdn.discordapp.com/avatars/${presence.discord_user.id}/${presence.discord_user.avatar}`
|
||||
: `https://cdn.discordapp.com/embed/avatars/${presence.discord_user.discriminator || 1 % 5}`;
|
||||
colors = await getImageColors(avatar, true);
|
||||
}
|
||||
|
||||
const ejsTemplateData: EjsTemplateData = {
|
||||
title: presence.discord_user.global_name || presence.discord_user.username,
|
||||
username:
|
||||
|
@ -53,6 +62,7 @@ async function handler(): Promise<Response> {
|
|||
readme,
|
||||
allowSnow: presence.kv.snow === "true",
|
||||
allowRain: presence.kv.rain === "true",
|
||||
colors: colors?.colors ?? {},
|
||||
};
|
||||
|
||||
return await renderEjsTemplate("index", ejsTemplateData);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue