add new player tracking logging and add discord link to the footer
This commit is contained in:
@ -13,8 +13,9 @@
|
||||
"@elysiajs/swagger": "^1.1.3",
|
||||
"@ssr/common": "workspace:common",
|
||||
"@tqman/nice-logger": "^1.0.1",
|
||||
"@vercel/og": "^0.6.3",
|
||||
"@typegoose/typegoose": "^12.8.0",
|
||||
"@vercel/og": "^0.6.3",
|
||||
"discord-webhook-node": "^1.1.8",
|
||||
"elysia": "latest",
|
||||
"elysia-autoroutes": "^0.5.0",
|
||||
"elysia-decorators": "^1.0.2",
|
||||
|
@ -1,4 +1,5 @@
|
||||
export const Config = {
|
||||
mongoUri: process.env.MONGO_URI,
|
||||
apiUrl: process.env.API_URL || "https://ssr.fascinated.cc/api",
|
||||
trackedPlayerWebhook: process.env.TRACKED_PLAYERS_WEBHOOK,
|
||||
};
|
||||
|
@ -5,6 +5,10 @@ import { scoresaberService } from "@ssr/common/service/impl/scoresaber";
|
||||
import ScoreSaberPlayerToken from "@ssr/common/types/token/scoresaber/score-saber-player-token";
|
||||
import { InternalServerError } from "../error/internal-server-error";
|
||||
import ScoreSaberPlayerScoreToken from "@ssr/common/types/token/scoresaber/score-saber-player-score-token";
|
||||
// @ts-ignore
|
||||
import { MessageBuilder, Webhook } from "discord-webhook-node";
|
||||
import { Config } from "../common/config";
|
||||
import { formatPp } from "@ssr/common/utils/number-utils";
|
||||
|
||||
export class PlayerService {
|
||||
/**
|
||||
@ -34,6 +38,20 @@ export class PlayerService {
|
||||
player = (await PlayerModel.create({ _id: id })) as PlayerDocument;
|
||||
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);
|
||||
} catch (err) {
|
||||
const message = `Failed to create player document for "${id}"`;
|
||||
console.log(message, err);
|
||||
|
Reference in New Issue
Block a user