guild specific banking data
This commit is contained in:
6 files changed
+289
-167
No files matched your search
@@ -0,0 +1,41 @@
|
||||
const mongoose = require('mongoose');
|
||||
|
||||
let bankSchema = mongoose.Schema({
|
||||
banking: {
|
||||
userID: String,
|
||||
guilds: {}
|
||||
}
|
||||
});
|
||||
|
||||
bankSchema.methods.createBank = function (userID, guildID, startingBalance) {
|
||||
this.banking.userID = userID;
|
||||
const newGuild = {
|
||||
account: {
|
||||
balance: startingBalance,
|
||||
cash: 0.00,
|
||||
}
|
||||
};
|
||||
this.bank.guilds[guildID] = newGuild
|
||||
};
|
||||
|
||||
// This function is to add a new guild specific inventory to an already existing
|
||||
// inventory document
|
||||
function addBank(guilds, guildID, userID, client, startingBalance) {
|
||||
let updatedGuilds = guilds;
|
||||
updatedGuilds[guildID] = {
|
||||
account: {
|
||||
balance: startingBalance,
|
||||
cash: 0.00,
|
||||
}
|
||||
}
|
||||
|
||||
client.dbo.collection("banking").updateOne({"banking.userID":userID}, {$set: {"banking.guilds": updatedGuilds}}, function(err, res) {
|
||||
if (err) return false
|
||||
})
|
||||
return true
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
Bank: mongoose.model('Bank', bankSchema),
|
||||
addBank: addBank,
|
||||
};
|
||||
Reference in new issue
Block a user