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

@ -15,7 +15,7 @@ import PlayerController from "./controller/player.controller";
import { PlayerService } from "./service/player.service";
import { cron } from "@elysiajs/cron";
import { scoresaberService } from "@ssr/common/service/impl/scoresaber";
import { delay } from "@ssr/common/utils/utils";
import { delay, isProduction } from "@ssr/common/utils/utils";
import { connectScoreSaberWebSocket } from "@ssr/common/websocket/scoresaber-websocket";
import ImageController from "./controller/image.controller";
import ReplayController from "./controller/replay.controller";
@ -24,6 +24,8 @@ import { Config } from "@ssr/common/config";
import { PlayerDocument, PlayerModel } from "@ssr/common/model/player";
import ScoresController from "./controller/scores.controller";
import LeaderboardController from "./controller/leaderboard.controller";
import { DiscordChannels, initDiscordBot, logToChannel } from "./bot/bot";
import { EmbedBuilder } from "discord.js";
// Load .env file
dotenv.config({
@ -40,6 +42,12 @@ connectScoreSaberWebSocket({
await PlayerService.trackScore(playerScore);
await ScoreService.notifyNumberOne(playerScore);
},
onDisconnect: error => {
logToChannel(
DiscordChannels.backendLogs,
new EmbedBuilder().setDescription(`ScoreSaber websocket disconnected: ${error}`)
);
},
});
export const app = new Elysia();
@ -179,6 +187,9 @@ app.use(swagger());
app.onStart(() => {
console.log("Listening on port http://localhost:8080");
if (isProduction()) {
initDiscordBot();
}
});
app.listen(8080);