guild specific banking data
This commit is contained in:
6 files changed
+289
-167
No files matched your search
+37
-16
@@ -78,23 +78,44 @@ module.exports = {
|
||||
|
||||
if (!banking) {
|
||||
banking = {
|
||||
account: {
|
||||
userID: interaction.member.user.id,
|
||||
balance: GuildDB.startingBalance,
|
||||
cash: 0.00,
|
||||
userID: interaction.member.user.id,
|
||||
guidls: {
|
||||
[guildID]: {
|
||||
account: {
|
||||
balance: GuildDB.startingBalance,
|
||||
cash: 0.00,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
client.dbo.collection("banking").insertOne(banking, function(err, res) {
|
||||
if (err) {
|
||||
client.log(err);
|
||||
const embed = new MessageEmbed()
|
||||
.setDescriptions(`**Internal Error:** ${err}\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
|
||||
.setColor("RED")
|
||||
|
||||
return interaction.send({ embeds: [embed] });
|
||||
}
|
||||
});
|
||||
// Register inventory for user
|
||||
let newBank = new Bank();
|
||||
newBank.createBank(interaction.member.user.id, GuildDB.serverID, GuildDB.startingBalance);
|
||||
newBank.save()
|
||||
.catch(err => {
|
||||
if (err) {
|
||||
client.log(err);
|
||||
const embed = new MessageEmbed()
|
||||
.setDescriptions(`**Internal Error:** ${err}\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
|
||||
.setColor("RED")
|
||||
|
||||
return interaction.send({ embeds: [embed] });
|
||||
}
|
||||
});
|
||||
|
||||
} else banking = banking.banking;
|
||||
|
||||
if (!client.exists(banking.guilds[guildDB.serverID])) {
|
||||
const success = addBank(banking.guilds, guildDB.serverID, interaction.member.user.id, client, guildDB.startingBalance);
|
||||
if (!success) {
|
||||
client.log(err);
|
||||
const embed = new MessageEmbed()
|
||||
.setDescriptions(`**Internal Error:** ${err}\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
|
||||
.setColor("RED")
|
||||
|
||||
return interaction.send({ embeds: [embed] });
|
||||
}
|
||||
}
|
||||
|
||||
let job, earned;
|
||||
@@ -104,9 +125,9 @@ module.exports = {
|
||||
let highestPayIndex = workPays.indexOf(Math.max(workPays))
|
||||
job = workRoles[highestPayIndex]
|
||||
earned = workPays[highestPayIndex]
|
||||
newBalance = banking.account.balance + earned
|
||||
newBalance = banking.guilds[guildDB.serverID].account.balance + earned
|
||||
|
||||
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:{[`banking.guilds.${guildDB.serverID}.account.balance`]:newBalance}}, function(err, res) {
|
||||
if (err) {
|
||||
client.log(err);
|
||||
const embed = new MessageEmbed()
|
||||
|
||||
Reference in new issue
Block a user