Files
toho-miku/util/general.js
Minzkraut 2ef1dfe7a7 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.
2023-01-02 22:49:46 +01:00

22 lines
572 B
JavaScript

const { Bot } = require("../models");
const crypto = require("crypto");
const { ReactionUserManager } = require("discord.js");
module.exports = {
name: "GeneralUtils",
getBotProperty: async function(property) {
let bot = await Bot.findOne();
return property ? bot[property] : bot;
},
setBotProperty: async function(property, value) {
let bot = await Bot.findOne();
bot[property] = value;
await bot.save();
},
generateLogID: async function() {
return crypto.randomBytes(4).toString("hex");
}
}