fix theme color
Some checks failed
Deploy Backend / deploy (push) Successful in 4m25s
Deploy Website / deploy (push) Failing after 2m45s

This commit is contained in:
Lee 2024-10-16 08:21:27 +01:00
parent cb7143ed3d
commit 1e8a9b9a59
5 changed files with 29 additions and 17 deletions

@ -10,6 +10,7 @@ import ScoreSaberPlayerScoreToken from "@ssr/common/types/token/scoresaber/score
import { MessageBuilder, Webhook } from "discord-webhook-node";
import { Config } from "../common/config";
import { formatPp } from "@ssr/common/utils/number-utils";
import { isProduction } from "@ssr/common/utils/utils";
export class PlayerService {
/**
@ -40,19 +41,22 @@ export class PlayerService {
player.trackedSince = new Date();
await this.seedPlayerHistory(player, playerToken);
const hook = new Webhook({
url: Config.trackedPlayerWebhook,
});
hook.setUsername("Player Tracker");
const embed = new MessageBuilder();
embed.setTitle("New Player Tracked");
embed.addField("Username", playerToken.name, true);
embed.addField("ID", playerToken.id, true);
embed.addField("PP", formatPp(playerToken.pp) + "pp", true);
embed.setDescription(`https://ssr.fascinated.cc/player/${playerToken.id}`);
embed.setThumbnail(playerToken.profilePicture);
embed.setColor("#00ff00");
await hook.send(embed);
// Only notify in production
if (isProduction()) {
const hook = new Webhook({
url: Config.trackedPlayerWebhook,
});
hook.setUsername("Player Tracker");
const embed = new MessageBuilder();
embed.setTitle("New Player Tracked");
embed.addField("Username", playerToken.name, true);
embed.addField("ID", playerToken.id, true);
embed.addField("PP", formatPp(playerToken.pp) + "pp", true);
embed.setDescription(`https://ssr.fascinated.cc/player/${playerToken.id}`);
embed.setThumbnail(playerToken.profilePicture);
embed.setColor("#00ff00");
await hook.send(embed);
}
} catch (err) {
const message = `Failed to create player document for "${id}"`;
console.log(message, err);

@ -4,9 +4,15 @@ import ScoreSaberPlayerScoreToken from "@ssr/common/types/token/scoresaber/score
import { MessageBuilder, Webhook } from "discord-webhook-node";
import { Config } from "../common/config";
import { formatPp } from "@ssr/common/utils/number-utils";
import { isProduction } from "@ssr/common/utils/utils";
export class ScoreService {
public static async notifyNumberOne(playerScore: ScoreSaberPlayerScoreToken) {
// Only notify in production
if (!isProduction()) {
return;
}
const { score, leaderboard } = playerScore;
const player = score.leaderboardPlayerInfo;

@ -118,7 +118,7 @@ export async function generateViewport(props: Props): Promise<Viewport> {
const color = await getAverageColor(player.avatar);
return {
themeColor: color.hex,
themeColor: color.color,
};
}

@ -20,10 +20,10 @@ export function getImageUrl(originalUrl: string) {
*/
export const getAverageColor = async (src: string) => {
try {
return await ky.get<{ hex: string }>(`${config.siteApi}/image/averagecolor/${encodeURIComponent(src)}`).json();
return await ky.get<{ color: string }>(`${config.siteApi}/image/averagecolor/${encodeURIComponent(src)}`).json();
} catch {
return {
hex: Colors.primary,
color: Colors.primary,
};
}
};

@ -32,7 +32,9 @@ export function ApiHealth() {
if (previousOnlineStatus.current !== online) {
toast({
title: `The API is now ${online ? "Online" : "Offline"}!`,
description: online ? "The API has recovered connectivity." : "The API has lost connectivity.",
description: online
? "The API has recovered connectivity."
: "The API has lost connectivity, some data may be unavailable.",
variant: online ? "success" : "destructive",
duration: 10_000, // 10 seconds
});