fix theme color
This commit is contained in:
parent
cb7143ed3d
commit
1e8a9b9a59
@ -10,6 +10,7 @@ import ScoreSaberPlayerScoreToken from "@ssr/common/types/token/scoresaber/score
|
|||||||
import { MessageBuilder, Webhook } from "discord-webhook-node";
|
import { MessageBuilder, Webhook } from "discord-webhook-node";
|
||||||
import { Config } from "../common/config";
|
import { Config } from "../common/config";
|
||||||
import { formatPp } from "@ssr/common/utils/number-utils";
|
import { formatPp } from "@ssr/common/utils/number-utils";
|
||||||
|
import { isProduction } from "@ssr/common/utils/utils";
|
||||||
|
|
||||||
export class PlayerService {
|
export class PlayerService {
|
||||||
/**
|
/**
|
||||||
@ -40,19 +41,22 @@ export class PlayerService {
|
|||||||
player.trackedSince = new Date();
|
player.trackedSince = new Date();
|
||||||
await this.seedPlayerHistory(player, playerToken);
|
await this.seedPlayerHistory(player, playerToken);
|
||||||
|
|
||||||
const hook = new Webhook({
|
// Only notify in production
|
||||||
url: Config.trackedPlayerWebhook,
|
if (isProduction()) {
|
||||||
});
|
const hook = new Webhook({
|
||||||
hook.setUsername("Player Tracker");
|
url: Config.trackedPlayerWebhook,
|
||||||
const embed = new MessageBuilder();
|
});
|
||||||
embed.setTitle("New Player Tracked");
|
hook.setUsername("Player Tracker");
|
||||||
embed.addField("Username", playerToken.name, true);
|
const embed = new MessageBuilder();
|
||||||
embed.addField("ID", playerToken.id, true);
|
embed.setTitle("New Player Tracked");
|
||||||
embed.addField("PP", formatPp(playerToken.pp) + "pp", true);
|
embed.addField("Username", playerToken.name, true);
|
||||||
embed.setDescription(`https://ssr.fascinated.cc/player/${playerToken.id}`);
|
embed.addField("ID", playerToken.id, true);
|
||||||
embed.setThumbnail(playerToken.profilePicture);
|
embed.addField("PP", formatPp(playerToken.pp) + "pp", true);
|
||||||
embed.setColor("#00ff00");
|
embed.setDescription(`https://ssr.fascinated.cc/player/${playerToken.id}`);
|
||||||
await hook.send(embed);
|
embed.setThumbnail(playerToken.profilePicture);
|
||||||
|
embed.setColor("#00ff00");
|
||||||
|
await hook.send(embed);
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
const message = `Failed to create player document for "${id}"`;
|
const message = `Failed to create player document for "${id}"`;
|
||||||
console.log(message, err);
|
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 { MessageBuilder, Webhook } from "discord-webhook-node";
|
||||||
import { Config } from "../common/config";
|
import { Config } from "../common/config";
|
||||||
import { formatPp } from "@ssr/common/utils/number-utils";
|
import { formatPp } from "@ssr/common/utils/number-utils";
|
||||||
|
import { isProduction } from "@ssr/common/utils/utils";
|
||||||
|
|
||||||
export class ScoreService {
|
export class ScoreService {
|
||||||
public static async notifyNumberOne(playerScore: ScoreSaberPlayerScoreToken) {
|
public static async notifyNumberOne(playerScore: ScoreSaberPlayerScoreToken) {
|
||||||
|
// Only notify in production
|
||||||
|
if (!isProduction()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const { score, leaderboard } = playerScore;
|
const { score, leaderboard } = playerScore;
|
||||||
const player = score.leaderboardPlayerInfo;
|
const player = score.leaderboardPlayerInfo;
|
||||||
|
|
||||||
|
@ -118,7 +118,7 @@ export async function generateViewport(props: Props): Promise<Viewport> {
|
|||||||
|
|
||||||
const color = await getAverageColor(player.avatar);
|
const color = await getAverageColor(player.avatar);
|
||||||
return {
|
return {
|
||||||
themeColor: color.hex,
|
themeColor: color.color,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,10 +20,10 @@ export function getImageUrl(originalUrl: string) {
|
|||||||
*/
|
*/
|
||||||
export const getAverageColor = async (src: string) => {
|
export const getAverageColor = async (src: string) => {
|
||||||
try {
|
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 {
|
} catch {
|
||||||
return {
|
return {
|
||||||
hex: Colors.primary,
|
color: Colors.primary,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -32,7 +32,9 @@ export function ApiHealth() {
|
|||||||
if (previousOnlineStatus.current !== online) {
|
if (previousOnlineStatus.current !== online) {
|
||||||
toast({
|
toast({
|
||||||
title: `The API is now ${online ? "Online" : "Offline"}!`,
|
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",
|
variant: online ? "success" : "destructive",
|
||||||
duration: 10_000, // 10 seconds
|
duration: 10_000, // 10 seconds
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user