begin guild specific data
This commit is contained in:
6 files changed
+182
-114
No files matched your search
+42
-15
@@ -2,32 +2,59 @@ const mongoose = require('mongoose');
|
||||
|
||||
let inventorySchema = mongoose.Schema({
|
||||
inventory: {
|
||||
userID: String,
|
||||
items: [],
|
||||
lastWork: Date,
|
||||
userID: String,
|
||||
guilds: {},
|
||||
}
|
||||
});
|
||||
|
||||
inventorySchema.methods.createInventory = function (userID) {
|
||||
this.inventory.userID = userID;
|
||||
this.inventory.items = [];
|
||||
let walletData = {
|
||||
inventorySchema.methods.createInventory = function (userID, guildID) {
|
||||
this.inventory.userID = userID;
|
||||
const newGuild = {
|
||||
items: [{
|
||||
name: 'Wallet',
|
||||
type: 'wallet',
|
||||
description: '`/inventory wallet` to view wallet',
|
||||
description: '`/wallet view` to view wallet',
|
||||
cash: 0.00,
|
||||
ID: {
|
||||
firstname: '',
|
||||
lastname: '',
|
||||
dob: ''
|
||||
}
|
||||
}
|
||||
this.inventory.items.push(walletData);
|
||||
this.inventory.lastWork = new Date('2000-01-01T00:00:00'); // garantee's they can work right after inventory create
|
||||
}],
|
||||
lastWork: new Date('2000-01-01T00:00:00') // garantee's they can work right after inventory create,
|
||||
};
|
||||
|
||||
inventorySchema.methods.addItem = function (item) {
|
||||
this.inventory.items.push(item);
|
||||
this.inventory.guilds[guildID] = newGuild
|
||||
};
|
||||
|
||||
module.exports = mongoose.model('Inventory', inventorySchema);
|
||||
inventorySchema.methods.addItem = function (guildID, item) {
|
||||
this.inventory.guilds[guildID].items.push(item);
|
||||
};
|
||||
|
||||
// This function is to add a new guild specific inventory to an already existing
|
||||
// inventory document
|
||||
function addInventory(guilds, guildID, userID, client) {
|
||||
let updatedGuilds = guilds;
|
||||
updatedGuilds[guildID] = {
|
||||
items: [{
|
||||
name: 'Wallet',
|
||||
type: 'wallet',
|
||||
description: '`/wallet view` to view wallet',
|
||||
cash: 0.00,
|
||||
ID: {
|
||||
firstname: '',
|
||||
lastname: '',
|
||||
dob: ''
|
||||
}
|
||||
}],
|
||||
}
|
||||
|
||||
client.dbo.collection("inventories").updateOne({"inventory.userID":userID}, {$set: {"inventory.guilds": updatedGuilds}}, function(err, res) {
|
||||
if (err) return false
|
||||
})
|
||||
return true
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
Inventory: mongoose.model('Inventory', inventorySchema),
|
||||
addInventory: addInventory,
|
||||
};
|
||||
Reference in new issue
Block a user