Trade: Persist trades in the database

using atomic transactions.
If a card happens to not be owned by the trading user, the entire
trade is being rolled back.
Rollback behaviour is a bit weird though, since we have to rollback
manually even in a managed transaction.
This commit is contained in:
2023-01-02 22:49:46 +01:00
parent 95c3f41fde
commit 2ef1dfe7a7
2 changed files with 50 additions and 3 deletions

View File

@@ -1,4 +1,6 @@
const { Bot } = require("../models");
const crypto = require("crypto");
const { ReactionUserManager } = require("discord.js");
module.exports = {
name: "GeneralUtils",
@@ -11,5 +13,9 @@ module.exports = {
let bot = await Bot.findOne();
bot[property] = value;
await bot.save();
},
generateLogID: async function() {
return crypto.randomBytes(4).toString("hex");
}
}