reset cmd/improve money cmd/fix settings cmd options

This commit is contained in:
SowinskiBraeden committed 2022-08-26 14:11:48 -07:00
1 parent 9bcfad7963
commit 63ceb3de84
5 files changed
+200 -126

No files matched your search

+24 -30
View File
@@ -1,5 +1,21 @@
const mongoose = require('mongoose');
const defaultGuildData = {
items: [{
name: 'Wallet',
type: 'wallet',
description: '`/wallet view` to view wallet',
cash: 0.00,
ID: {
firstname: '',
lastname: '',
dob: '',
addr: '',
}
}],
lastWork: new Date('2000-01-01T00:00:00') // garantee's they can work right after inventory create,
}
let inventorySchema = mongoose.Schema({
inventory: {
userID: String,
@@ -9,45 +25,23 @@ let inventorySchema = mongoose.Schema({
inventorySchema.methods.createInventory = function (userID, guildID) {
this.inventory.userID = userID;
const newGuild = {
items: [{
name: 'Wallet',
type: 'wallet',
description: '`/wallet view` to view wallet',
cash: 0.00,
ID: {
firstname: '',
lastname: '',
dob: ''
}
}],
lastWork: new Date('2000-01-01T00:00:00') // garantee's they can work right after inventory create,
};
this.inventory.guilds = {};
this.inventory.guilds[guildID] = newGuild
this.inventory.guilds[guildID] = defaultGuildData;
};
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
/*
This function is to add a new guild specific inventory to an already existing
inventory document
or
can be used to reset a data back to default
*/
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: ''
}
}],
}
updatedGuilds[guildID] = defaultGuildData;
client.dbo.collection("inventories").updateOne({"inventory.userID":userID}, {$set: {"inventory.guilds": updatedGuilds}}, function(err, res) {
if (err) return false