logs tiny fix

This commit is contained in:
Milo
2025-11-08 11:05:27 +01:00
parent 237d14c755
commit 0e690aebfc
3 changed files with 25 additions and 22 deletions

View File

@@ -10,24 +10,23 @@ import {
stripMentionsOfBot,
} from "../../utils/ai.js";
import {
formatTime,
postAPOBuy,
getAPOUsers,
getAkhys,
calculateBasePrice,
calculateMaxPrice,
formatTime,
getAkhys,
getAPOUsers,
postAPOBuy,
} from "../../utils/index.js";
import { channelPointsHandler, slowmodesHandler, randomSkinPrice, initTodaysSOTD } from "../../game/points.js";
import { requestTimestamps, activeSlowmodes, activePolls, skins, activeSolitaireGames } from "../../game/state.js";
import { channelPointsHandler, initTodaysSOTD, randomSkinPrice, slowmodesHandler } from "../../game/points.js";
import { activePolls, activeSlowmodes, requestTimestamps, skins } from "../../game/state.js";
import {
flopoDB,
getUser,
getAllUsers,
updateManyUsers,
insertUser,
updateUserAvatar,
getAllSkins,
getAllUsers,
getUser,
hardUpdateSkin,
updateManyUsers,
updateUserAvatar,
} from "../../database/index.js";
import { client } from "../client.js";
import { autoSolveMoves } from "../../game/solitaire.js";
@@ -57,7 +56,7 @@ export async function handleMessageCreate(message, client, io) {
// --- Main Guild Features (Points & Slowmode) ---
if (message.guildId === process.env.GUILD_ID) {
// Award points for activity
const pointsAwarded = await channelPointsHandler(message);
const pointsAwarded = channelPointsHandler(message);
if (pointsAwarded) {
io.emit("data-updated", { table: "users", action: "update" });
}

View File

@@ -225,7 +225,8 @@ export const stmtLogs = flopoDB.prepare(`
action TEXT,
target_user_id TEXT REFERENCES users,
coins_amount INTEGER,
user_new_amount INTEGER
user_new_amount INTEGER,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)
`);
stmtLogs.run();
@@ -358,7 +359,7 @@ export async function pruneOldLogs() {
FROM logs
WHERE id IN (SELECT id
FROM (SELECT id,
ROW_NUMBER() OVER (ORDER BY id DESC) AS rn
ROW_NUMBER() OVER (ORDER BY created_at DESC) AS rn
FROM logs
WHERE user_id = ?)
WHERE rn > ${process.env.LOGS_BY_USER})

View File

@@ -1,16 +1,17 @@
import {
getUser,
updateUserCoins,
insertLog,
getAllSkins,
insertSOTD,
clearSOTDStats,
getAllSOTDStats,
deleteSOTD,
getAllSkins,
getAllSOTDStats,
getUser,
insertGame,
insertLog,
insertSOTD,
pruneOldLogs,
updateUserCoins
} from "../database/index.js";
import { messagesTimestamps, activeSlowmodes, skins } from "./state.js";
import { deal, createSeededRNG, seededShuffle, createDeck } from "./solitaire.js";
import { activeSlowmodes, messagesTimestamps, skins } from "./state.js";
import { createDeck, createSeededRNG, deal, seededShuffle } from "./solitaire.js";
/**
* Handles awarding points (coins) to users for their message activity.
@@ -65,6 +66,8 @@ export async function channelPointsHandler(message) {
user_new_amount: newCoinTotal,
});
await pruneOldLogs();
return true; // Indicate that points were awarded
}