mirror of
https://github.com/cassoule/flopobot_v2.git
synced 2026-03-18 21:40:27 +01:00
some fixes
This commit is contained in:
@@ -245,10 +245,8 @@ async function handleAdminCommands(message) {
|
||||
try {
|
||||
const stmt = flopoDB.prepare(sqlCommand);
|
||||
const result = sqlCommand.trim().toUpperCase().startsWith("SELECT") ? stmt.all() : stmt.run();
|
||||
console.log(result);
|
||||
message.reply("```json\n" + JSON.stringify(result, null, 2).substring(0, 1900) + "\n```");
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
message.reply(`SQL Error: ${e.message}`);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -332,6 +332,11 @@ export function apiRoutes(client, io) {
|
||||
if (skin.user_id !== userId) {
|
||||
return res.status(403).json({ error: "User does not own this skin." });
|
||||
}
|
||||
const marketOffers = getMarketOffersBySkin.all(skin.uuid);
|
||||
const activeOffers = marketOffers.filter((offer) => offer.status === "pending" || offer.status === "open");
|
||||
if (activeOffers.length > 0) {
|
||||
return res.status(403).json({ error: "Impossible d'améliorer ce skin, une offre FlopoMarket est en cours." });
|
||||
}
|
||||
const { successProb, destructionProb, upgradePrice } = getSkinUpgradeProbs(skin, skinData);
|
||||
|
||||
const commandUser = getUser.get(userId);
|
||||
|
||||
@@ -36,6 +36,7 @@ export function monkeRoutes(client, io) {
|
||||
const user = getUser.get(userId);
|
||||
if (!user) return res.status(404).json({ error: "User not found" });
|
||||
if (!initialBet) return res.status(400).json({ error: "Initial bet is required" });
|
||||
if (initialBet > user.coins) return res.status(400).json({ error: "Insufficient coins for the initial bet" });
|
||||
|
||||
try {
|
||||
const newCoins = user.coins - initialBet;
|
||||
|
||||
Reference in New Issue
Block a user