fix #3, now tracking cheers and cheerEvents in database, minor tweaks to existing code

This commit is contained in:
2025-08-24 20:20:52 +02:00
parent 97a6a599a8
commit 594d154cab
13 changed files with 108 additions and 15 deletions

View File

@@ -8,6 +8,8 @@ import cheers from "cheers";
import logger from "lib/logger";
import { addMessageToChatWidget } from "web/chatWidget/message";
import { isInvuln, setTemporaryInvuln } from "lib/invuln";
import { getUserRecord } from "db/dbUser";
import { createCheerRecord } from "db/dbCheers";
logger.info(`Loaded the following commands: ${commands.keys().toArray().join(', ')}`);
@@ -65,6 +67,11 @@ async function handleChatMessage(msg: EventSubChannelChatMessageEvent, user: Use
};
export async function handleCheer(msg: EventSubChannelChatMessageEvent, bits: number, user: User) {
if (msg.isCheer) {
await getUserRecord(user); // ensure they exist in the database
await createCheerRecord(user, bits);
}; // If this is not triggered it's because of the testcheer command. these fake bits should not be added to the database
const selection = cheers.get(bits);
if (!selection) return;