remove cash system
This commit is contained in:
9 files changed
+38
-238
No files matched your search
+12
-191
@@ -12,34 +12,6 @@ module.exports = {
|
|||||||
member: [],
|
member: [],
|
||||||
},
|
},
|
||||||
options: [
|
options: [
|
||||||
{
|
|
||||||
name: "deposit",
|
|
||||||
description: "Deposit cash into your bank",
|
|
||||||
value: "deposit",
|
|
||||||
type: 1,
|
|
||||||
options: [{
|
|
||||||
name: "amount",
|
|
||||||
description: "Amount to deposit",
|
|
||||||
value: "amount",
|
|
||||||
type: 10,
|
|
||||||
min_value: 0.01,
|
|
||||||
required: true,
|
|
||||||
}]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "withdraw",
|
|
||||||
description: "Withdraw cash from you bank",
|
|
||||||
value: "deposit",
|
|
||||||
type: 1,
|
|
||||||
options: [{
|
|
||||||
name: "amount",
|
|
||||||
description: "Amount to withdraw",
|
|
||||||
value: "amount",
|
|
||||||
type: 10,
|
|
||||||
min_value: 0.01,
|
|
||||||
required: true,
|
|
||||||
}]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: "balance",
|
name: "balance",
|
||||||
description: "View your bank balance and count your cash",
|
description: "View your bank balance and count your cash",
|
||||||
@@ -53,29 +25,6 @@ module.exports = {
|
|||||||
required: false,
|
required: false,
|
||||||
}]
|
}]
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: "give",
|
|
||||||
description: "Give a user cash",
|
|
||||||
value: "give",
|
|
||||||
type: 1,
|
|
||||||
options: [
|
|
||||||
{
|
|
||||||
name: "user",
|
|
||||||
description: "User to give cash to",
|
|
||||||
value: "user",
|
|
||||||
type: 6,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "amount",
|
|
||||||
description: "The amount to give",
|
|
||||||
value: "amount",
|
|
||||||
type: 10,
|
|
||||||
min_value: 0.01,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: "transfer",
|
name: "transfer",
|
||||||
description: "Transfer directly to users bank",
|
description: "Transfer directly to users bank",
|
||||||
@@ -120,17 +69,14 @@ module.exports = {
|
|||||||
userID: interaction.member.user.id,
|
userID: interaction.member.user.id,
|
||||||
guilds: {
|
guilds: {
|
||||||
[GuildDB.serverID]: {
|
[GuildDB.serverID]: {
|
||||||
bankAccount: {
|
balance: GuildDB.startingBalance,
|
||||||
balance: GuildDB.startingBalance,
|
|
||||||
cash: 0.00,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register bank for user
|
// Register bank for user
|
||||||
let newBank = new User();
|
let newBank = new User();
|
||||||
newBank.createUser(interaction.member.user.id, GuildDB.serverID, GuildDB.startingBalance, 0);
|
newBank.createUser(interaction.member.user.id, GuildDB.serverID, GuildDB.startingBalance);
|
||||||
newBank.save().catch(err => {
|
newBank.save().catch(err => {
|
||||||
if (err) return client.sendInternalError(interaction, err);
|
if (err) return client.sendInternalError(interaction, err);
|
||||||
});
|
});
|
||||||
@@ -142,63 +88,7 @@ module.exports = {
|
|||||||
if (!success) return client.sendInternalError(interaction, 'Failed to add bank');
|
if (!success) return client.sendInternalError(interaction, 'Failed to add bank');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[0].name == 'deposit') {
|
if (args[0].name == 'balance') {
|
||||||
if (banking.guilds[GuildDB.serverID].bankAccount.cash.toFixed(2) - args[0].options[0].value < 0) {
|
|
||||||
const nsf = new EmbedBuilder()
|
|
||||||
.setDescription('**Bank Notice:** NSF. Non sufficient funds')
|
|
||||||
.setColor(client.config.Colors.Red);
|
|
||||||
|
|
||||||
return interaction.send({ embeds: [nsf] });
|
|
||||||
}
|
|
||||||
|
|
||||||
const newBalance = banking.guilds[GuildDB.serverID].bankAccount.balance + args[0].options[0].value;
|
|
||||||
const newCash = Math.abs(banking.guilds[GuildDB.serverID].bankAccount.cash.toFixed(2) - args[0].options[0].value);
|
|
||||||
|
|
||||||
client.dbo.collection("users").updateOne({ "user.userID": interaction.member.user.id }, {
|
|
||||||
$set: {
|
|
||||||
[`user.guilds.${GuildDB.serverID}.bankAccount.balance`]: newBalance,
|
|
||||||
[`user.guilds.${GuildDB.serverID}.bankAccount.cash`]: newCash
|
|
||||||
}
|
|
||||||
}, function(err, res) {
|
|
||||||
if (err) return client.sendInternalError(interaction, err);
|
|
||||||
});
|
|
||||||
|
|
||||||
const successEmbed = new EmbedBuilder()
|
|
||||||
.setTitle('Bank Notice:')
|
|
||||||
.setDescription(`Successfully deposited **$${args[0].options[0].value.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2})}**\nUse \`/bank balance\` to view your balance`)
|
|
||||||
.setColor(client.config.Colors.Green);
|
|
||||||
|
|
||||||
return interaction.send({ embeds: [successEmbed] });
|
|
||||||
|
|
||||||
} else if (args[0].name == 'withdraw') {
|
|
||||||
if (args[0].options[0].value > banking.guilds[GuildDB.serverID].bankAccount.balance) {
|
|
||||||
let nsf = new EmbedBuilder()
|
|
||||||
.setDescription('**Bank Notice:** NSF. Non sufficient funds')
|
|
||||||
.setColor(client.config.Colors.Red);
|
|
||||||
|
|
||||||
return interaction.send({ embeds: [nsf] });
|
|
||||||
}
|
|
||||||
|
|
||||||
const newBalance = banking.guilds[GuildDB.serverID].bankAccount.balance - args[0].options[0].value;
|
|
||||||
const newCash = banking.guilds[GuildDB.serverID].bankAccount.cash + args[0].options[0].value;
|
|
||||||
|
|
||||||
client.dbo.collection("users").updateOne({ "user.userID": interaction.member.user.id }, {
|
|
||||||
$set: {
|
|
||||||
[`user.guilds.${GuildDB.serverID}.bankAccount.balance`]: newBalance,
|
|
||||||
[`user.guilds.${GuildDB.serverID}.bankAccount.cash`]: newCash
|
|
||||||
}
|
|
||||||
}, function(err, res) {
|
|
||||||
if (err) return client.sendInternalError(interaction, err);
|
|
||||||
});
|
|
||||||
|
|
||||||
const successEmbed = new EmbedBuilder()
|
|
||||||
.setTitle('Bank Notice:')
|
|
||||||
.setDescription(`Successfully withdrew **$${args[0].options[0].value.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2})}**\nUse \`/bank balance\` to view your cash balance`)
|
|
||||||
.setColor(client.config.Colors.Green);
|
|
||||||
|
|
||||||
return interaction.send({ embeds: [successEmbed] });
|
|
||||||
|
|
||||||
} else if (args[0].name == 'balance') {
|
|
||||||
let balanceEmbed = new EmbedBuilder()
|
let balanceEmbed = new EmbedBuilder()
|
||||||
.setColor(client.config.Colors.Default);
|
.setColor(client.config.Colors.Default);
|
||||||
|
|
||||||
@@ -213,10 +103,7 @@ module.exports = {
|
|||||||
userID: targetUserID,
|
userID: targetUserID,
|
||||||
guilds: {
|
guilds: {
|
||||||
[GuildDB.serverID]: {
|
[GuildDB.serverID]: {
|
||||||
bankAccount: {
|
balance: GuildDB.startingBalance,
|
||||||
balance: GuildDB.startingBalance,
|
|
||||||
cash: 0.00,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -240,85 +127,22 @@ module.exports = {
|
|||||||
|
|
||||||
balanceEmbed.setTitle(`${DiscordUser.tag.split("#")[0]}'s Bank Records`);
|
balanceEmbed.setTitle(`${DiscordUser.tag.split("#")[0]}'s Bank Records`);
|
||||||
balanceEmbed.addFields(
|
balanceEmbed.addFields(
|
||||||
{ name: '**Cash**', value: `$${targetUserBanking.guilds[GuildDB.serverID].bankAccount.cash.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2})}`, inline: true },
|
{ name: '**Bank**', value: `$${targetUserBanking.guilds[GuildDB.serverID].balance.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2})}`, inline: true },
|
||||||
{ name: '**Bank**', value: `$${targetUserBanking.guilds[GuildDB.serverID].bankAccount.balance.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2})}`, inline: true },
|
|
||||||
{ name: '**Total**', value: `$${(targetUserBanking.guilds[GuildDB.serverID].bankAccount.balance + targetUserBanking.guilds[GuildDB.serverID].bankAccount.cash).toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2})}`, inline: true });
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Show command authors balance
|
// Show command authors balance
|
||||||
|
|
||||||
balanceEmbed.setTitle('Personal Bank Records');
|
balanceEmbed.setTitle('Personal Bank Records');
|
||||||
balanceEmbed.addFields(
|
balanceEmbed.addFields(
|
||||||
{ name: '**Cash**', value: `$${banking.guilds[GuildDB.serverID].bankAccount.cash.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2})}`, inline: true },
|
{ name: '**Bank**', value: `$${banking.guilds[GuildDB.serverID].balance.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2})}`, inline: true },
|
||||||
{ name: '**Bank**', value: `$${banking.guilds[GuildDB.serverID].bankAccount.balance.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2})}`, inline: true },
|
|
||||||
{ name: '**Total**', value: `$${(banking.guilds[GuildDB.serverID].bankAccount.balance + banking.guilds[GuildDB.serverID].bankAccount.cash).toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2})}`, inline: true });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return interaction.send({ embeds: [balanceEmbed] });
|
return interaction.send({ embeds: [balanceEmbed] });
|
||||||
|
|
||||||
} else if (args[0].name == 'give') {
|
|
||||||
// send money from wallet
|
|
||||||
|
|
||||||
if (banking.guilds[GuildDB.serverID].bankAccount.cash.toFixed(2) - args[0].options[1].value < 0) {
|
|
||||||
let embed = new EmbedBuilder()
|
|
||||||
.setDescription('**Bank Notice:** NSF. Non sufficient funds')
|
|
||||||
.setColor(client.config.Colors.Red);
|
|
||||||
|
|
||||||
return interaction.send({ embeds: [embed] });
|
|
||||||
}
|
|
||||||
|
|
||||||
const newCash = banking.guilds[GuildDB.serverID].bankAccount.cash - args[0].options[1].value;
|
|
||||||
|
|
||||||
client.dbo.collection("users").updateOne({ "user.userID": interaction.member.user.id }, {
|
|
||||||
$set: {
|
|
||||||
[`user.guilds.${GuildDB.serverID}.bankAccount.cash`]: newCash
|
|
||||||
}
|
|
||||||
}, function(err, res) {
|
|
||||||
if (err) return client.sendInternalError(interaction, err);
|
|
||||||
});
|
|
||||||
|
|
||||||
const targetUserID = args[0].options[0].value.replace('<@!', '').replace('>', '');
|
|
||||||
let targetUserBanking = await client.dbo.collection("users").findOne({"user.userID": targetUserID}).then(banking => banking);
|
|
||||||
|
|
||||||
let newTargetCash = targetUserBanking.guilds[GuildDB.serverID].bankAccount.cash + args[0].options[1].value;
|
|
||||||
|
|
||||||
if (!targetUserBanking) {
|
|
||||||
targetUserBanking = {
|
|
||||||
userID: targetUserID,
|
|
||||||
guilds: {
|
|
||||||
[GuildDB.serverID]: {
|
|
||||||
bankAccount: {
|
|
||||||
balance: GuildDB.startingBalance,
|
|
||||||
cash: newTargetCash,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Register bank for user
|
|
||||||
let newBank = new User();
|
|
||||||
newBank.createUser(targetUserID, GuildDB.serverID, GuildDB.startingBalance, newTargetCash);
|
|
||||||
newBank.save().catch(err => {
|
|
||||||
if (err) return client.sendInternalError(interaction, err);
|
|
||||||
});
|
|
||||||
} else targetUserBanking = targetUserBanking.user;
|
|
||||||
|
|
||||||
if (!client.exists(targetUserBanking.guilds[GuildDB.serverID])) {
|
|
||||||
const success = addUser(targetUserBanking.guilds, GuildDB.serverID, targetUserID, client, GuildDB.startingBalance);
|
|
||||||
if (!success) return client.sendInternalError(interaction, 'Failed to add bank');
|
|
||||||
}
|
|
||||||
|
|
||||||
const successEmbed = new EmbedBuilder()
|
|
||||||
.setTitle('Success')
|
|
||||||
.setDescription(`Successfully gave <@${targetUserID}> **$${args[0].options[1].value.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2})}**`)
|
|
||||||
.setColor(client.config.Colors.Green);
|
|
||||||
|
|
||||||
return interaction.send({ embeds: [successEmbed] });
|
|
||||||
|
|
||||||
} else if (args[0].name == 'transfer') {
|
} else if (args[0].name == 'transfer') {
|
||||||
// send money from bank
|
// send money from bank
|
||||||
|
|
||||||
if (banking.guilds[GuildDB.serverID].bankAccount.balance.toFixed(2) - args[0].options[1].value < 0) {
|
if (banking.guilds[GuildDB.serverID].balance.toFixed(2) - args[0].options[1].value < 0) {
|
||||||
let embed = new EmbedBuilder()
|
let embed = new EmbedBuilder()
|
||||||
.setTitle('**Bank Notice:** NSF. Non sufficient funds')
|
.setTitle('**Bank Notice:** NSF. Non sufficient funds')
|
||||||
.setColor(client.config.Colors.Red);
|
.setColor(client.config.Colors.Red);
|
||||||
@@ -326,9 +150,9 @@ module.exports = {
|
|||||||
return interaction.send({ embeds: [embed] });
|
return interaction.send({ embeds: [embed] });
|
||||||
}
|
}
|
||||||
|
|
||||||
const newBalance = banking.guilds[GuildDB.serverID].bankAccount.balance - args[0].options[1].value;
|
const newBalance = banking.guilds[GuildDB.serverID].balance - args[0].options[1].value;
|
||||||
|
|
||||||
client.dbo.collection("users").updateOne({"user.userID":interaction.member.user.id},{$set:{[`user.guilds.${GuildDB.serverID}.bankAccount.balance`]:newBalance}}, function(err, res) {
|
client.dbo.collection("users").updateOne({"user.userID":interaction.member.user.id},{$set:{[`user.guilds.${GuildDB.serverID}.balance`]:newBalance}}, function(err, res) {
|
||||||
if (err) return client.sendInternalError(interaction, err);
|
if (err) return client.sendInternalError(interaction, err);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -340,10 +164,7 @@ module.exports = {
|
|||||||
userID: targetUserID,
|
userID: targetUserID,
|
||||||
guilds: {
|
guilds: {
|
||||||
[GuildDB.serverID]: {
|
[GuildDB.serverID]: {
|
||||||
bankAccount: {
|
balance: (GuildDB.startingBalance + args[0].options[1].value),
|
||||||
balance: (GuildDB.startingBalance + args[0].options[1].value),
|
|
||||||
cash: 0.00,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -353,9 +174,9 @@ module.exports = {
|
|||||||
});
|
});
|
||||||
} else targetUserBanking = targetUserBanking.user;
|
} else targetUserBanking = targetUserBanking.user;
|
||||||
|
|
||||||
const newTargetBalance = targetUserBanking.guilds[GuildDB.serverID].bankAccount.balance + args[0].options[1].value;
|
const newTargetBalance = targetUserBanking.guilds[GuildDB.serverID].balance + args[0].options[1].value;
|
||||||
|
|
||||||
client.dbo.collection("users").updateOne({"user.userID":targetUserID},{$set:{[`user.guilds.${GuildDB.serverID}.bankAccount.balance`]:newTargetBalance}}, function(err, res) {
|
client.dbo.collection("users").updateOne({"user.userID":targetUserID},{$set:{[`user.guilds.${GuildDB.serverID}.balance`]:newTargetBalance}}, function(err, res) {
|
||||||
if (err) return client.sendInternalError(interaction, err);
|
if (err) return client.sendInternalError(interaction, err);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
+5
-8
@@ -58,17 +58,14 @@ module.exports = {
|
|||||||
userID: interaction.member.user.id,
|
userID: interaction.member.user.id,
|
||||||
guilds: {
|
guilds: {
|
||||||
[GuildDB.serverID]: {
|
[GuildDB.serverID]: {
|
||||||
bankAccount: {
|
balance: GuildDB.startingBalance,
|
||||||
balance: GuildDB.startingBalance,
|
|
||||||
cash: 0.00,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register bank for user
|
// Register bank for user
|
||||||
let newBank = new User();
|
let newBank = new User();
|
||||||
newBank.createUser(interaction.member.user.id, GuildDB.serverID, GuildDB.startingBalance, 0);
|
newBank.createUser(interaction.member.user.id, GuildDB.serverID, GuildDB.startingBalance);
|
||||||
newBank.save().catch(err => {
|
newBank.save().catch(err => {
|
||||||
if (err) return client.sendInternalError(interaction, err);
|
if (err) return client.sendInternalError(interaction, err);
|
||||||
});
|
});
|
||||||
@@ -80,7 +77,7 @@ module.exports = {
|
|||||||
if (!success) return client.sendInternalError(interaction, 'Failed to add bank');
|
if (!success) return client.sendInternalError(interaction, 'Failed to add bank');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[0].options[0].value > banking.guilds[GuildDB.serverID].bankAccount.balance) {
|
if (args[0].options[0].value > banking.guilds[GuildDB.serverID].balance) {
|
||||||
let nsf = new EmbedBuilder()
|
let nsf = new EmbedBuilder()
|
||||||
.setDescription('**Bank Notice:** NSF. Non sufficient funds')
|
.setDescription('**Bank Notice:** NSF. Non sufficient funds')
|
||||||
.setColor(client.config.Colors.Red);
|
.setColor(client.config.Colors.Red);
|
||||||
@@ -88,11 +85,11 @@ module.exports = {
|
|||||||
return interaction.send({ embeds: [nsf] });
|
return interaction.send({ embeds: [nsf] });
|
||||||
}
|
}
|
||||||
|
|
||||||
const newBalance = banking.guilds[GuildDB.serverID].bankAccount.balance - args[0].options[1].value;
|
const newBalance = banking.guilds[GuildDB.serverID].balance - args[0].options[1].value;
|
||||||
|
|
||||||
client.dbo.collection("users").updateOne({ "user.userID": interaction.member.user.id }, {
|
client.dbo.collection("users").updateOne({ "user.userID": interaction.member.user.id }, {
|
||||||
$set: {
|
$set: {
|
||||||
[`user.guilds.${GuildDB.serverID}.bankAccount.balance`]: newBalance,
|
[`user.guilds.${GuildDB.serverID}.balance`]: newBalance,
|
||||||
}
|
}
|
||||||
}, function(err, res) {
|
}, function(err, res) {
|
||||||
if (err) return client.sendInternalError(interaction, err);
|
if (err) return client.sendInternalError(interaction, err);
|
||||||
|
|||||||
@@ -46,10 +46,7 @@ module.exports = {
|
|||||||
userID: interaction.member.user.id,
|
userID: interaction.member.user.id,
|
||||||
guilds: {
|
guilds: {
|
||||||
[GuildDB.serverID]: {
|
[GuildDB.serverID]: {
|
||||||
bankAccount: {
|
balance: GuildDB.startingBalance,
|
||||||
balance: GuildDB.startingBalance,
|
|
||||||
cash: 0.00,
|
|
||||||
},
|
|
||||||
lastIncome: new Date('2000-01-01T00:00:00'),
|
lastIncome: new Date('2000-01-01T00:00:00'),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -57,7 +54,7 @@ module.exports = {
|
|||||||
|
|
||||||
// Register bank for user
|
// Register bank for user
|
||||||
let newBank = new User();
|
let newBank = new User();
|
||||||
newBank.createUser(interaction.member.user.id, GuildDB.serverID, GuildDB.startingBalance, 0);
|
newBank.createUser(interaction.member.user.id, GuildDB.serverID, GuildDB.startingBalance);
|
||||||
newBank.save().catch(err => {
|
newBank.save().catch(err => {
|
||||||
if (err) return client.sendInternalError(interaction, err);
|
if (err) return client.sendInternalError(interaction, err);
|
||||||
});
|
});
|
||||||
@@ -87,7 +84,7 @@ module.exports = {
|
|||||||
let totalIncome = income.reduce((x, y) => x + y, 0)
|
let totalIncome = income.reduce((x, y) => x + y, 0)
|
||||||
|
|
||||||
let newData = banking.guilds[GuildDB.serverID];
|
let newData = banking.guilds[GuildDB.serverID];
|
||||||
newData.bankAccount.balance += totalIncome;
|
newData.balance += totalIncome;
|
||||||
newData.lastIncome = now;
|
newData.lastIncome = now;
|
||||||
|
|
||||||
client.dbo.collection("users").updateOne({"user.userID":interaction.member.user.id},{$set:{[`user.guilds.${GuildDB.serverID}`]: newData}}, function(err, res) {
|
client.dbo.collection("users").updateOne({"user.userID":interaction.member.user.id},{$set:{[`user.guilds.${GuildDB.serverID}`]: newData}}, function(err, res) {
|
||||||
|
|||||||
@@ -51,10 +51,8 @@ module.exports = {
|
|||||||
|
|
||||||
let users = await client.dbo.collection("users").find({}).toArray();
|
let users = await client.dbo.collection("users").find({}).toArray();
|
||||||
|
|
||||||
users.map(u => u.user.guilds[GuildDB.serverID].bankAccount.total = u.user.guilds[GuildDB.serverID].bankAccount.balance + u.user.guilds[GuildDB.serverID].bankAccount.cash);
|
|
||||||
|
|
||||||
leaderboard = users.sort(function(a, b) {
|
leaderboard = users.sort(function(a, b) {
|
||||||
return b.user.guilds[GuildDB.serverID].bankAccount.total - a.user.guilds[GuildDB.serverID].bankAccount.total;
|
return b.user.guilds[GuildDB.serverID].balance - a.user.guilds[GuildDB.serverID].balance;
|
||||||
});
|
});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -71,7 +69,6 @@ module.exports = {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
let limit = args[1].value > leaderboard.length ? leaderboard.length : args[1].value;
|
let limit = args[1].value > leaderboard.length ? leaderboard.length : args[1].value;
|
||||||
|
|
||||||
let leaderboardEmbed = new EmbedBuilder()
|
let leaderboardEmbed = new EmbedBuilder()
|
||||||
@@ -97,7 +94,7 @@ module.exports = {
|
|||||||
category == 'deathstreak' ? `${leaderboard[i].deathStreak} Deathstreak` :
|
category == 'deathstreak' ? `${leaderboard[i].deathStreak} Deathstreak` :
|
||||||
category == 'worst_deathstreak' ? `${leaderboard[i].worstDeathStreak} Deathstreak` :
|
category == 'worst_deathstreak' ? `${leaderboard[i].worstDeathStreak} Deathstreak` :
|
||||||
category == 'longest_kill' ? `${leaderboard[i].longestKill}m` :
|
category == 'longest_kill' ? `${leaderboard[i].longestKill}m` :
|
||||||
category == 'money' ? `$${(leaderboard[i].user.guilds[GuildDB.serverID].bankAccount.total).toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2})}` : 'N/A Error';
|
category == 'money' ? `$${(leaderboard[i].user.guilds[GuildDB.serverID].balance).toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2})}` : 'N/A Error';
|
||||||
|
|
||||||
if (category == 'money') des += `**${i+1}.** <@${leaderboard[i].user.userID}> - **${stats}**\n`
|
if (category == 'money') des += `**${i+1}.** <@${leaderboard[i].user.userID}> - **${stats}**\n`
|
||||||
else leaderboardEmbed.addFields({ name: `**${i+1}. ${leaderboard[i].gamertag}**`, value: `**${stats}**`, inline: true });
|
else leaderboardEmbed.addFields({ name: `**${i+1}. ${leaderboard[i].gamertag}**`, value: `**${stats}**`, inline: true });
|
||||||
|
|||||||
+5
-8
@@ -84,17 +84,14 @@ module.exports = {
|
|||||||
userID: targetUserID,
|
userID: targetUserID,
|
||||||
guilds: {
|
guilds: {
|
||||||
[GuildDB.serverID]: {
|
[GuildDB.serverID]: {
|
||||||
bankAccount: {
|
balance: GuildDB.startingBalance,
|
||||||
balance: GuildDB.startingBalance,
|
|
||||||
cash: 0.00,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register bank for user
|
// Register bank for user
|
||||||
let newBank = new User();
|
let newBank = new User();
|
||||||
await newBank.createUser(targetUserID, GuildDB.serverID, GuildDB.startingBalance, 0);
|
await newBank.createUser(targetUserID, GuildDB.serverID, GuildDB.startingBalance);
|
||||||
await newBank.save().catch(err => {
|
await newBank.save().catch(err => {
|
||||||
if (err) return client.sendInternalError(interaction, err);
|
if (err) return client.sendInternalError(interaction, err);
|
||||||
});
|
});
|
||||||
@@ -107,10 +104,10 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let newBalance = args[0].name == 'add'
|
let newBalance = args[0].name == 'add'
|
||||||
? banking.guilds[GuildDB.serverID].bankAccount.balance + args[0].options[0].value
|
? banking.guilds[GuildDB.serverID].balance + args[0].options[0].value
|
||||||
: banking.guilds[GuildDB.serverID].bankAccount.balance - args[0].options[0].value;
|
: banking.guilds[GuildDB.serverID].balance - args[0].options[0].value;
|
||||||
|
|
||||||
client.dbo.collection("users").updateOne({"user.userID":targetUserID},{$set:{[`user.guilds.${GuildDB.serverID}.bankAccount.balance`]:newBalance}}, function(err, res) {
|
client.dbo.collection("users").updateOne({"user.userID":targetUserID},{$set:{[`user.guilds.${GuildDB.serverID}.balance`]:newBalance}}, function(err, res) {
|
||||||
if (err) return client.sendInternalError(interaction, err);
|
if (err) return client.sendInternalError(interaction, err);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ module.exports = {
|
|||||||
if (!success) return client.sendInternalError(interaction, 'Failed to add bank');
|
if (!success) return client.sendInternalError(interaction, 'Failed to add bank');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (banking.guilds[GuildDB.serverID].bankAccount.balance.toFixed(2) - GuildDB.uavPrice < 0) {
|
if (banking.guilds[GuildDB.serverID].balance.toFixed(2) - GuildDB.uavPrice < 0) {
|
||||||
let embed = new EmbedBuilder()
|
let embed = new EmbedBuilder()
|
||||||
.setTitle('**Bank Notice:** NSF. Non sufficient funds')
|
.setTitle('**Bank Notice:** NSF. Non sufficient funds')
|
||||||
.setColor(client.config.Colors.Red);
|
.setColor(client.config.Colors.Red);
|
||||||
@@ -76,9 +76,9 @@ module.exports = {
|
|||||||
return interaction.send({ embeds: [embed] });
|
return interaction.send({ embeds: [embed] });
|
||||||
}
|
}
|
||||||
|
|
||||||
const newBalance = banking.guilds[GuildDB.serverID].bankAccount.balance - GuildDB.uavPrice;
|
const newBalance = banking.guilds[GuildDB.serverID].balance - GuildDB.uavPrice;
|
||||||
|
|
||||||
client.dbo.collection("users").updateOne({"user.userID":interaction.member.user.id},{$set:{[`user.guilds.${GuildDB.serverID}.bankAccount.balance`]:newBalance}}, function(err, res) {
|
client.dbo.collection("users").updateOne({"user.userID":interaction.member.user.id},{$set:{[`user.guilds.${GuildDB.serverID}.balance`]:newBalance}}, function(err, res) {
|
||||||
if (err) return client.sendInternalError(interaction, err);
|
if (err) return client.sendInternalError(interaction, err);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "dayz-armbands",
|
"name": "dayz-armbands",
|
||||||
"version": "6.9.0",
|
"version": "6.10.0",
|
||||||
"description": "A General Purpose Discord Bot for DayZ Servers.",
|
"description": "A General Purpose Discord Bot for DayZ Servers.",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"nodemonConfig": {
|
"nodemonConfig": {
|
||||||
|
|||||||
+3
-9
@@ -7,14 +7,11 @@ let userSchema = mongoose.Schema({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
userSchema.methods.createUser = function (userID, guildID, startingBalance, cash) {
|
userSchema.methods.createUser = function (userID, guildID, startingBalance) {
|
||||||
this.user.userID = userID;
|
this.user.userID = userID;
|
||||||
this.user.guilds = {};
|
this.user.guilds = {};
|
||||||
this.user.guilds[guildID] = {
|
this.user.guilds[guildID] = {
|
||||||
bankAccount: {
|
balance: startingBalance,
|
||||||
balance: startingBalance,
|
|
||||||
cash: cash,
|
|
||||||
},
|
|
||||||
lastIncome: new Date('2000-01-01T00:00:00'),
|
lastIncome: new Date('2000-01-01T00:00:00'),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -28,10 +25,7 @@ userSchema.methods.createUser = function (userID, guildID, startingBalance, cash
|
|||||||
function addUser(guilds, guildID, userID, client, startingBalance) {
|
function addUser(guilds, guildID, userID, client, startingBalance) {
|
||||||
let updatedGuilds = guilds;
|
let updatedGuilds = guilds;
|
||||||
updatedGuilds[guildID] = {
|
updatedGuilds[guildID] = {
|
||||||
bankAccount: {
|
balance: startingBalance,
|
||||||
balance: startingBalance,
|
|
||||||
cash: 0.00,
|
|
||||||
},
|
|
||||||
lastIncome: new Date('2000-01-01T00:00:00')
|
lastIncome: new Date('2000-01-01T00:00:00')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -101,17 +101,14 @@ module.exports = {
|
|||||||
userID: killerStat.discordID,
|
userID: killerStat.discordID,
|
||||||
guilds: {
|
guilds: {
|
||||||
[guildId]: {
|
[guildId]: {
|
||||||
bankAccount: {
|
balance: guild.startingBalance,
|
||||||
balance: guild.startingBalance,
|
|
||||||
cash: 0.00,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register bank for user
|
// Register bank for user
|
||||||
let newBank = new User();
|
let newBank = new User();
|
||||||
newBank.createUser(killerStat.discordID, guildId, guild.startingBalance, 0);
|
newBank.createUser(killerStat.discordID, guildId, guild.startingBalance);
|
||||||
newBank.save().catch(err => {
|
newBank.save().catch(err => {
|
||||||
if (err) return client.sendInternalError(interaction, err);
|
if (err) return client.sendInternalError(interaction, err);
|
||||||
});
|
});
|
||||||
@@ -123,11 +120,11 @@ module.exports = {
|
|||||||
if (!success) return client.sendError(guild.connectionLogsChannel, 'Failed to add bank');
|
if (!success) return client.sendError(guild.connectionLogsChannel, 'Failed to add bank');
|
||||||
}
|
}
|
||||||
|
|
||||||
const newBalance = banking.guilds[guildId].bankAccount.balance + totalBounty;
|
const newBalance = banking.guilds[guildId].balance + totalBounty;
|
||||||
|
|
||||||
await client.dbo.collection("users").updateOne({ "user.userID": killerStat.discordID }, {
|
await client.dbo.collection("users").updateOne({ "user.userID": killerStat.discordID }, {
|
||||||
$set: {
|
$set: {
|
||||||
[`user.guilds.${guildId}.bankAccount.balance`]: newBalance,
|
[`user.guilds.${guildId}.balance`]: newBalance,
|
||||||
}
|
}
|
||||||
}, function(err, res) {
|
}, function(err, res) {
|
||||||
if (err) return client.sendError(guild.connectionLogsChannel, err);
|
if (err) return client.sendError(guild.connectionLogsChannel, err);
|
||||||
|
|||||||
Reference in new issue
Block a user