inventory command handlers

This commit is contained in:
SowinskiBraeden committed 2022-07-04 22:21:44 -07:00
1 parent 91f60417aa
commit 20344e1471
8 files changed
+715 -1441

No files matched your search

+4
View File
@@ -1,5 +1,6 @@
const { Collection, Client, MessageEmbed } = require('discord.js');
const MongoClient = require('mongodb').MongoClient;
const mongoose = require('mongoose');
const Logger = require("../util/Logger");
const path = require("path");
const fs = require('fs');
@@ -61,8 +62,11 @@ class QuarksBot extends Client {
}
async connectMongo(mongoURI, dbo) {
// Connect to MongoDB database.
this.db = await MongoClient.connect(mongoURI);
this.dbo = this.db.db(dbo);
mongoose.connect(`${mongoURI}/${dbo}`);
this.log('Successfully connected to mongoDB');
}
+35
View File
@@ -0,0 +1,35 @@
const mongoose = require('mongoose');
let inventorySchema = mongoose.Schema({
inventory: {
userID: String,
items: [],
createdAt: Date,
updatedAt: Date
}
});
inventorySchema.methods.createInventory = function (userID) {
this.inventory.userID = userID;
this.inventory.items = [];
let walletData = {
name: 'Wallet',
type: 'wallet',
description: '`/inventory wallet` to view wallet',
cash: 0.00,
ID: {
firstname: '',
lastname: '',
dob: ''
}
}
this.inventory.items.push(walletData);
this.inventory.createdAt = new Date();
this.inventory.updatedAt = this.inventory.createdAt;
};
inventorySchema.methods.addItem = function (item) {
this.inventory.items.push(item);
};
module.exports = mongoose.model('Inventory', inventorySchema);