fix work command
This commit is contained in:
1 file changed
+23
-12
+23
-12
@@ -1,5 +1,5 @@
|
||||
const { MessageEmbed, } = require('discord.js');
|
||||
const Inventory = require('./inventory');
|
||||
const Inventory = require('../structures/inventory');
|
||||
|
||||
module.exports = {
|
||||
name: "work",
|
||||
@@ -51,16 +51,17 @@ module.exports = {
|
||||
.catch(err => {
|
||||
if (err) {
|
||||
client.log(err);
|
||||
let embed = new MessageEmbed()
|
||||
.setTitle(err)
|
||||
const embed = new MessageEmbed()
|
||||
.setDescriptions(`**Internal Error:** ${err}\nContact the Developers`)
|
||||
.setColor("RED")
|
||||
|
||||
|
||||
return interaction.send({ embeds: [embed] });
|
||||
}
|
||||
});
|
||||
} else inventory = inventory.inventory
|
||||
|
||||
const msBetweenDates = Math.abs(then.getTime() - now.getTime())
|
||||
const now = new Date();
|
||||
const msBetweenDates = Math.abs(inventory.lastWork - now)
|
||||
const hoursBetweenDates = msBetweenDates / (60 * 60 * 1000)
|
||||
|
||||
if (hoursBetweenDates >= 24) {
|
||||
@@ -87,10 +88,10 @@ module.exports = {
|
||||
client.dbo.collection("banking").insertOne(banking, function(err, res) {
|
||||
if (err) {
|
||||
client.log(err);
|
||||
let embed = new MessageEmbed()
|
||||
.setTitle(err)
|
||||
const embed = new MessageEmbed()
|
||||
.setDescriptions(`**Internal Error:** ${err}\nContact the Developers`)
|
||||
.setColor("RED")
|
||||
|
||||
|
||||
return interaction.send({ embeds: [embed] });
|
||||
}
|
||||
});
|
||||
@@ -108,8 +109,19 @@ module.exports = {
|
||||
client.dbo.collection("banking").updateOne({"account.userID":interaction.member.user.id},{$set:{"account.balance":newBalance}}, function(err, res) {
|
||||
if (err) {
|
||||
client.log(err);
|
||||
let embed = new MessageEmbed()
|
||||
.setTitle(err)
|
||||
const embed = new MessageEmbed()
|
||||
.setDescriptions(`**Internal Error:** ${err}\nContact the Developers`)
|
||||
.setColor("RED")
|
||||
|
||||
return interaction.send({ embeds: [embed] });
|
||||
}
|
||||
});
|
||||
|
||||
client.dbo.collection("inventories").updateOne({"inventory.userID":interaction.member.user.id}, {$set: {'inventory.lastWork': now}}, function(err, res) {
|
||||
if (err) {
|
||||
client.log(err);
|
||||
const embed = new MessageEmbed()
|
||||
.setDescriptions(`**Internal Error:** ${err}\nContact the Developers`)
|
||||
.setColor("RED")
|
||||
|
||||
return interaction.send({ embeds: [embed] });
|
||||
@@ -118,7 +130,6 @@ module.exports = {
|
||||
|
||||
const success = new MessageEmbed()
|
||||
.setColor('GREEN')
|
||||
.setTitle('Worked')
|
||||
.setDescription(`You worked your job <@&${job}> and earned $${earned}.`)
|
||||
|
||||
return interaction.send({ embeds: [success] })
|
||||
@@ -126,7 +137,7 @@ module.exports = {
|
||||
} else {
|
||||
const error = new MessageEmbed()
|
||||
.setColor(client.config.EmbedColor)
|
||||
.setTitle('Take a rest')
|
||||
.setTitle('Take a rest...')
|
||||
.setDescription(`You've already worked a full day today. Take a rest and work tomorrow.`)
|
||||
|
||||
return interaction.send({ embeds: [error] })
|
||||
|
||||
Reference in new issue
Block a user