a super shitty discord bot but i needed logging
Some checks failed
Deploy Backend / deploy (push) Failing after 1m29s
Deploy Website / deploy (push) Has been cancelled

This commit is contained in:
Lee
2024-10-17 18:29:30 +01:00
parent 373a6355a6
commit a086bebc40
8 changed files with 122 additions and 34 deletions

View File

@ -4,7 +4,6 @@ import ScoreSaberPlayerScoreToken from "@ssr/common/types/token/scoresaber/score
import { MessageBuilder, Webhook } from "discord-webhook-node";
import { formatPp } from "@ssr/common/utils/number-utils";
import { isProduction } from "@ssr/common/utils/utils";
import { Config } from "@ssr/common/config";
import { Metadata } from "@ssr/common/types/metadata";
import { NotFoundError } from "elysia";
import BeatSaverService from "./beatsaver.service";
@ -20,6 +19,8 @@ import { PlayerScore } from "@ssr/common/score/player-score";
import LeaderboardScoresResponse from "@ssr/common/response/leaderboard-scores-response";
import Score from "@ssr/common/score/score";
import PlayerScoresResponse from "@ssr/common/response/player-scores-response";
import { DiscordChannels, logToChannel } from "../bot/bot";
import { EmbedBuilder } from "discord.js";
export class ScoreService {
/**
@ -45,20 +46,20 @@ export class ScoreService {
return;
}
const hook = new Webhook({
url: Config.numberOneWebhook,
});
hook.setUsername("Number One Feed");
const embed = new MessageBuilder();
embed.setTitle(`${player.name} set a #${score.rank} on ${leaderboard.songName} ${leaderboard.songSubName}`);
embed.setDescription(`
**Player:** https://ssr.fascinated.cc/player/${player.id}
**Leaderboard:** https://ssr.fascinated.cc/leaderboard/${leaderboard.id}
**PP:** ${formatPp(score.pp)}
`);
embed.setThumbnail(leaderboard.coverImage);
embed.setColor("#00ff00");
await hook.send(embed);
logToChannel(
DiscordChannels.numberOneFeed,
new EmbedBuilder()
.setTitle(`${player.name} set a #1 on ${leaderboard.songName} ${leaderboard.songSubName}`)
.setDescription(
`
**Player:** https://ssr.fascinated.cc/player/${player.id}
**Leaderboard:** https://ssr.fascinated.cc/leaderboard/${leaderboard.id}
**PP:** ${formatPp(score.pp)}
`
)
.setThumbnail(leaderboard.coverImage)
.setColor("#00ff00")
);
}
/**