begin guild specific data

This commit is contained in:
SowinskiBraeden committed 2022-08-17 14:27:53 -07:00
1 parent 66bc081884
commit 80376b648a
6 files changed
+182 -114

No files matched your search

+4 -4
View File
@@ -1,5 +1,5 @@
const { MessageEmbed, } = require('discord.js');
const Inventory = require('../structures/inventory');
const { Inventory, addInventory } = require('../structures/inventory');
module.exports = {
name: "work",
@@ -42,11 +42,11 @@ module.exports = {
if (!inventory) {
// if the inventory previously didn't exists, this is the only information we require
inventory = {lastWork: new Date('2000-01-01T00:00:00')} // Early date ensures they can work
inventory = {guilds: {[guillDB.serverID]: {lastWork: new Date('2000-01-01T00:00:00')}}} // Early date ensures they can work
// Register inventory for user
let newInventory = new Inventory();
newInventory.createInventory(interaction.member.user.id);
newInventory.createInventory(interaction.member.user.id, guildDB.serverID);
newInventory.save()
.catch(err => {
if (err) {
@@ -117,7 +117,7 @@ module.exports = {
}
});
client.dbo.collection("inventories").updateOne({"inventory.userID":interaction.member.user.id}, {$set: {'inventory.lastWork': now}}, function(err, res) {
client.dbo.collection("inventories").updateOne({"inventory.userID":interaction.member.user.id}, {$set: {[`inventory.guilds.${guildDB.serverID}.lastWork`]: now}}, function(err, res) {
if (err) {
client.log(err);
const embed = new MessageEmbed()