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