5.0.0 dev v3 channel / data collection tests
This commit is contained in:
7 files changed
+301
-99
No files matched your search
+43
-43
@@ -1,5 +1,5 @@
|
||||
const { EmbedBuilder } = require('discord.js');
|
||||
const { Bank, addBank } = require('../structures/bank');
|
||||
const { User, addUser } = require('../structures/user');
|
||||
|
||||
module.exports = {
|
||||
name: "bank",
|
||||
@@ -113,14 +113,14 @@ module.exports = {
|
||||
return interaction.send({ content: `You are not allowed to use the bot in this channel.`, flags: (1 << 6) });
|
||||
}
|
||||
|
||||
let banking = await client.dbo.collection("banks").findOne({"banking.userID": interaction.member.user.id}).then(banking => banking);
|
||||
let banking = await client.dbo.collection("users").findOne({"user.userID": interaction.member.user.id}).then(banking => banking);
|
||||
|
||||
if (!banking) {
|
||||
banking = {
|
||||
userID: interaction.member.user.id,
|
||||
guilds: {
|
||||
[GuildDB.serverID]: {
|
||||
account: {
|
||||
bankAccount: {
|
||||
balance: GuildDB.startingBalance,
|
||||
cash: 0.00,
|
||||
}
|
||||
@@ -129,7 +129,7 @@ module.exports = {
|
||||
}
|
||||
|
||||
// Register inventory for user
|
||||
let newBank = new Bank();
|
||||
let newBank = new User();
|
||||
newBank.createBank(interaction.member.user.id, GuildDB.serverID, GuildDB.startingBalance, 0);
|
||||
newBank.save().catch(err => {
|
||||
if (err) return client.sendInternalError(interaction, err);
|
||||
@@ -138,12 +138,12 @@ module.exports = {
|
||||
} 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);
|
||||
const success = addUser(banking.guilds, GuildDB.serverID, interaction.member.user.id, client, GuildDB.startingBalance);
|
||||
if (!success) return client.sendInternalError(interaction, 'Failed to add bank');
|
||||
}
|
||||
|
||||
if (args[0].name == 'deposit') {
|
||||
if (banking.guilds[GuildDB.serverID].account.cash.toFixed(2) - args[0].options[0].value < 0) {
|
||||
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);
|
||||
@@ -151,13 +151,13 @@ module.exports = {
|
||||
return interaction.send({ embeds: [nsf] });
|
||||
}
|
||||
|
||||
const newBalance = banking.guilds[GuildDB.serverID].account.balance + args[0].options[0].value;
|
||||
const newCash = Math.abs(banking.guilds[GuildDB.serverID].account.cash.toFixed(2) - args[0].options[0].value);
|
||||
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("banks").updateOne({ "banking.userID": interaction.member.user.id }, {
|
||||
client.dbo.collection("users").updateOne({ "user.userID": interaction.member.user.id }, {
|
||||
$set: {
|
||||
[`banking.guilds.${GuildDB.serverID}.account.balance`]: newBalance,
|
||||
[`banking.guilds.${GuildDB.serverID}.account.cash`]: newCash
|
||||
[`banking.guilds.${GuildDB.serverID}.bankAccount.balance`]: newBalance,
|
||||
[`banking.guilds.${GuildDB.serverID}.bankAccount.cash`]: newCash
|
||||
}
|
||||
}, function(err, res) {
|
||||
if (err) return client.sendInternalError(interaction, err);
|
||||
@@ -171,7 +171,7 @@ module.exports = {
|
||||
return interaction.send({ embeds: [successEmbed] });
|
||||
|
||||
} else if (args[0].name == 'withdraw') {
|
||||
if (args[0].options[0].value > banking.guilds[GuildDB.serverID].account.balance) {
|
||||
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);
|
||||
@@ -179,13 +179,13 @@ module.exports = {
|
||||
return interaction.send({ embeds: [nsf] });
|
||||
}
|
||||
|
||||
const newBalance = banking.guilds[GuildDB.serverID].account.balance - args[0].options[0].value;
|
||||
const newCash = banking.guilds[GuildDB.serverID].account.cash + args[0].options[0].value;
|
||||
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("banks").updateOne({ "banking.userID": interaction.member.user.id }, {
|
||||
client.dbo.collection("users").updateOne({ "user.userID": interaction.member.user.id }, {
|
||||
$set: {
|
||||
[`banking.guilds.${GuildDB.serverID}.account.balance`]: newBalance,
|
||||
[`banking.guilds.${GuildDB.serverID}.account.cash`]: newCash
|
||||
[`banking.guilds.${GuildDB.serverID}.bankAccount.balance`]: newBalance,
|
||||
[`banking.guilds.${GuildDB.serverID}.bankAccount.cash`]: newCash
|
||||
}
|
||||
}, function(err, res) {
|
||||
if (err) return client.sendInternalError(interaction, err);
|
||||
@@ -206,14 +206,14 @@ module.exports = {
|
||||
// Show target users balance
|
||||
|
||||
let targetUserID = args[0].options[0].value.replace('<@!', '').replace('>', '');
|
||||
let targetUserBanking = await client.dbo.collection("banks").findOne({"banking.userID": targetUserID}).then(banking => banking);
|
||||
let targetUserBanking = await client.dbo.collection("users").findOne({"user.userID": targetUserID}).then(banking => banking);
|
||||
|
||||
if (!targetUserBanking) {
|
||||
targetUserBanking = {
|
||||
userID: targetUserID,
|
||||
guilds: {
|
||||
[GuildDB.serverID]: {
|
||||
account: {
|
||||
bankAccount: {
|
||||
balance: GuildDB.startingBalance,
|
||||
cash: 0.00,
|
||||
}
|
||||
@@ -222,7 +222,7 @@ module.exports = {
|
||||
}
|
||||
|
||||
// Register inventory for user
|
||||
let newBank = new Bank();
|
||||
let newBank = new User();
|
||||
newBank.createBank(targetUserID, GuildDB.serverID, GuildDB.startingBalance, 0);
|
||||
newBank.save().catch(err => {
|
||||
if (err) return client.sendInternalError(interaction, err);
|
||||
@@ -231,7 +231,7 @@ module.exports = {
|
||||
} else targetUserBanking = targetUserBanking.banking;
|
||||
|
||||
if (!client.exists(targetUserBanking.guilds[GuildDB.serverID])) {
|
||||
const success = addBank(targetUserBanking.guilds, GuildDB.serverID, targetUserID, client, GuildDB.startingBalance);
|
||||
const success = addUser(targetUserBanking.guilds, GuildDB.serverID, targetUserID, client, GuildDB.startingBalance);
|
||||
if (!success) return client.sendInternalError(interaction, 'Failed to add bank');
|
||||
}
|
||||
|
||||
@@ -240,17 +240,17 @@ module.exports = {
|
||||
|
||||
balanceEmbed.setTitle(`${User.tag}'s Bank Records`);
|
||||
balanceEmbed.addFields(
|
||||
{ name: '**Bank**', value: `$${targetUserBanking.guilds[GuildDB.serverID].account.balance}`, inline: true },
|
||||
{ name: '**Cash**', value: `$${targetUserBanking.guilds[GuildDB.serverID].account.cash}`, inline: true });
|
||||
{ name: '**Bank**', value: `$${targetUserBanking.guilds[GuildDB.serverID].bankAccount.balance}`, inline: true },
|
||||
{ name: '**Cash**', value: `$${targetUserBanking.guilds[GuildDB.serverID].bankAccount.cash}`, inline: true });
|
||||
|
||||
} else {
|
||||
// Show command authors balance
|
||||
|
||||
balanceEmbed.setTitle('Personal Bank Records');
|
||||
balanceEmbed.addFields(
|
||||
{ name: '**Bank**', value: `$${banking.guilds[GuildDB.serverID].account.balance.toFixed(2)}`, inline: true },
|
||||
{ name: '**Cash**', value: `$${banking.guilds[GuildDB.serverID].account.cash.toFixed(2)}`, inline: true },
|
||||
{ name: '**Total**', value: `$${(banking.guilds[GuildDB.serverID].account.balance + banking.guilds[GuildDB.serverID].account.cash).toFixed(2)}`, inline: true });
|
||||
{ name: '**Bank**', value: `$${banking.guilds[GuildDB.serverID].bankAccount.balance.toFixed(2)}`, inline: true },
|
||||
{ name: '**Cash**', value: `$${banking.guilds[GuildDB.serverID].bankAccount.cash.toFixed(2)}`, inline: true },
|
||||
{ name: '**Total**', value: `$${(banking.guilds[GuildDB.serverID].bankAccount.balance + banking.guilds[GuildDB.serverID].bankAccount.cash).toFixed(2)}`, inline: true });
|
||||
}
|
||||
|
||||
return interaction.send({ embeds: [balanceEmbed] });
|
||||
@@ -258,7 +258,7 @@ module.exports = {
|
||||
} else if (args[0].name == 'give') {
|
||||
// send money from wallet
|
||||
|
||||
if (banking.guilds[GuildDB.serverID].account.cash.toFixed(2) - args[0].options[1].value < 0) {
|
||||
if (banking.guilds[GuildDB.serverID].bankAccount.cash.toFixed(2) - args[0].options[1].value < 0) {
|
||||
let embed = new EmbedBuilder()
|
||||
.setTitle('Non sufficient funds! Withdraw more cash')
|
||||
.setColor(client.config.Colors.Red);
|
||||
@@ -266,27 +266,27 @@ module.exports = {
|
||||
return interaction.send({ embeds: [embed] });
|
||||
}
|
||||
|
||||
const newCash = banking.guilds[GuildDB.serverID].account.cash - args[0].options[1].value;
|
||||
const newCash = banking.guilds[GuildDB.serverID].bankAccount.cash - args[0].options[1].value;
|
||||
|
||||
client.dbo.collection("banks").updateOne({ "banking.userID": interaction.member.user.id }, {
|
||||
client.dbo.collection("users").updateOne({ "user.userID": interaction.member.user.id }, {
|
||||
$set: {
|
||||
[`banking.guilds.${GuildDB.serverID}.account.cash`]: newCash
|
||||
[`banking.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("banks").findOne({"banking.userID": targetUserID}).then(banking => banking);
|
||||
let targetUserBanking = await client.dbo.collection("users").findOne({"user.userID": targetUserID}).then(banking => banking);
|
||||
|
||||
let newTargetCash = targetUserBanking.guilds[GuildDB.serverID].account.cash + args[0].options[1].value;
|
||||
let newTargetCash = targetUserBanking.guilds[GuildDB.serverID].bankAccount.cash + args[0].options[1].value;
|
||||
|
||||
if (!targetUserBanking) {
|
||||
targetUserBanking = {
|
||||
userID: targetUserID,
|
||||
guilds: {
|
||||
[GuildDB.serverID]: {
|
||||
account: {
|
||||
bankAccount: {
|
||||
balance: GuildDB.startingBalance,
|
||||
cash: newTargetCash,
|
||||
}
|
||||
@@ -295,7 +295,7 @@ module.exports = {
|
||||
}
|
||||
|
||||
// Register inventory for user
|
||||
let newBank = new Bank();
|
||||
let newBank = new User();
|
||||
newBank.createBank(targetUserID, GuildDB.serverID, GuildDB.startingBalance, newTargetCash);
|
||||
newBank.save().catch(err => {
|
||||
if (err) return client.sendInternalError(interaction, err);
|
||||
@@ -303,7 +303,7 @@ module.exports = {
|
||||
} else targetUserBanking = targetUserBanking.banking;
|
||||
|
||||
if (!client.exists(targetUserBanking.guilds[GuildDB.serverID])) {
|
||||
const success = addBank(targetUserBanking.guilds, GuildDB.serverID, targetUserID, client, GuildDB.startingBalance);
|
||||
const success = addUser(targetUserBanking.guilds, GuildDB.serverID, targetUserID, client, GuildDB.startingBalance);
|
||||
if (!success) return client.sendInternalError(interaction, 'Failed to add bank');
|
||||
}
|
||||
|
||||
@@ -317,7 +317,7 @@ module.exports = {
|
||||
} else if (args[0].name == 'transfer') {
|
||||
// send money from bank
|
||||
|
||||
if (banking.guilds[GuildDB.serverID].account.balance.toFixed(2) - args[0].options[1].value < 0) {
|
||||
if (banking.guilds[GuildDB.serverID].bankAccount.balance.toFixed(2) - args[0].options[1].value < 0) {
|
||||
let embed = new EmbedBuilder()
|
||||
.setTitle('Non sufficient funds! Withdraw more cash')
|
||||
.setColor(client.config.Colors.Red);
|
||||
@@ -325,21 +325,21 @@ module.exports = {
|
||||
return interaction.send({ embeds: [embed] });
|
||||
}
|
||||
|
||||
const newBalance = banking.guilds[GuildDB.serverID].account.balance - args[0].options[1].value;
|
||||
const newBalance = banking.guilds[GuildDB.serverID].bankAccount.balance - args[0].options[1].value;
|
||||
|
||||
client.dbo.collection("banks").updateOne({"banking.userID":interaction.member.user.id},{$set:{[`banking.guilds.${GuildDB.serverID}.account.balance`]:newBalance}}, function(err, res) {
|
||||
client.dbo.collection("users").updateOne({"user.userID":interaction.member.user.id},{$set:{[`banking.guilds.${GuildDB.serverID}.bankAccount.balance`]:newBalance}}, 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("banks").findOne({"banking.userID": targetUserID}).then(banking => banking);
|
||||
let targetUserBanking = await client.dbo.collection("users").findOne({"user.userID": targetUserID}).then(banking => banking);
|
||||
|
||||
if (!targetUserBanking) {
|
||||
targetUserBanking = {
|
||||
userID: targetUserID,
|
||||
guilds: {
|
||||
[GuildDB.serverID]: {
|
||||
account: {
|
||||
bankAccount: {
|
||||
balance: (GuildDB.startingBalance + args[0].options[1].value),
|
||||
cash: 0.00,
|
||||
}
|
||||
@@ -347,14 +347,14 @@ module.exports = {
|
||||
}
|
||||
}
|
||||
|
||||
client.dbo.collection("banks").insertOne(targetUserBanking, function(err, res) {
|
||||
client.dbo.collection("users").insertOne(targetUserBanking, function(err, res) {
|
||||
if (err) return client.sendInternalError(interaction, err);
|
||||
});
|
||||
} else targetUserBanking = targetUserBanking.banking;
|
||||
|
||||
const newTargetBalance = targetUserBanking.guilds[GuildDB.serverID].account.balance + args[0].options[1].value;
|
||||
const newTargetBalance = targetUserBanking.guilds[GuildDB.serverID].bankAccount.balance + args[0].options[1].value;
|
||||
|
||||
client.dbo.collection("banks").updateOne({"banking.userID":targetUserID},{$set:{[`banking.guilds.${GuildDB.serverID}.account.balance`]:newTargetBalance}}, function(err, res) {
|
||||
client.dbo.collection("users").updateOne({"user.userID":targetUserID},{$set:{[`banking.guilds.${GuildDB.serverID}.bankAccount.balance`]:newTargetBalance}}, function(err, res) {
|
||||
if (err) return client.sendInternalError(interaction, err);
|
||||
});
|
||||
|
||||
|
||||
+8
-8
@@ -1,5 +1,5 @@
|
||||
const { EmbedBuilder } = require('discord.js');
|
||||
const { Bank, addBank } = require('../structures/bank');
|
||||
const { User, addUser } = require('../structures/user');
|
||||
const bitfieldCalculator = require('discord-bitfield-calculator');
|
||||
|
||||
module.exports = {
|
||||
@@ -77,14 +77,14 @@ module.exports = {
|
||||
if (!canUseCommand) return interaction.send({ content: 'You don\'t have the permissions to use this command.' });
|
||||
|
||||
const targetUserID = args[0].options[1].value.replace('<@!', '').replace('>', '');
|
||||
let banking = await client.dbo.collection("banks").findOne({"banking.userID": targetUserID}).then(banking => banking);
|
||||
let banking = await client.dbo.collection("users").findOne({"user.userID": targetUserID}).then(banking => banking);
|
||||
|
||||
if (!banking) {
|
||||
banking = {
|
||||
userID: targetUserID,
|
||||
guilds: {
|
||||
[GuildDB.serverID]: {
|
||||
account: {
|
||||
bankAccount: {
|
||||
balance: GuildDB.startingBalance,
|
||||
cash: 0.00,
|
||||
}
|
||||
@@ -93,7 +93,7 @@ module.exports = {
|
||||
}
|
||||
|
||||
// Register inventory for user
|
||||
let newBank = new Bank();
|
||||
let newBank = new User();
|
||||
newBank.createBank(targetUserID, GuildDB.serverID, GuildDB.startingBalance, 0);
|
||||
newBank.save().catch(err => {
|
||||
if (err) return client.sendInternalError(interaction, err);
|
||||
@@ -102,15 +102,15 @@ module.exports = {
|
||||
} else banking = banking.banking;
|
||||
|
||||
if (!client.exists(banking.guilds[GuildDB.serverID])) {
|
||||
const success = addBank(banking.guilds, GuildDB.serverID, targetUserID, client, GuildDB.startingBalance);
|
||||
const success = addUser(banking.guilds, GuildDB.serverID, targetUserID, client, GuildDB.startingBalance);
|
||||
if (!success) return client.sendInternalError(interaction, 'Failed to add bank');
|
||||
}
|
||||
|
||||
let newBalance = args[0].name == 'add'
|
||||
? banking.guilds[GuildDB.serverID].account.balance + args[0].options[0].value
|
||||
: banking.guilds[GuildDB.serverID].account.balance - args[0].options[0].value;
|
||||
? banking.guilds[GuildDB.serverID].bankAccount.balance + args[0].options[0].value
|
||||
: banking.guilds[GuildDB.serverID].bankAccount.balance - args[0].options[0].value;
|
||||
|
||||
client.dbo.collection("banks").updateOne({"banking.userID":targetUserID},{$set:{[`banking.guilds.${GuildDB.serverID}.account.balance`]:newBalance}}, function(err, res) {
|
||||
client.dbo.collection("users").updateOne({"user.userID":targetUserID},{$set:{[`banking.guilds.${GuildDB.serverID}.bankAccount.balance`]:newBalance}}, function(err, res) {
|
||||
if (err) return client.sendInternalError(interaction, err);
|
||||
});
|
||||
|
||||
|
||||
Generated
+187
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "dayz-armbands",
|
||||
"version": "4.7.2",
|
||||
"version": "5.0.0.1",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "dayz-armbands",
|
||||
"version": "4.7.2",
|
||||
"version": "5.0.0.1",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@discordjs/rest": "^1.1.0",
|
||||
@@ -15,6 +15,7 @@
|
||||
"discord.js": "^14.3.0",
|
||||
"dotenv": "^16.0.2",
|
||||
"mongodb": "^4.12.1",
|
||||
"mongoose": "^7.0.1",
|
||||
"winston": "^3.8.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -1387,6 +1388,27 @@
|
||||
"integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/debug": {
|
||||
"version": "4.3.4",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
|
||||
"integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==",
|
||||
"dependencies": {
|
||||
"ms": "2.1.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"supports-color": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/debug/node_modules/ms": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
||||
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
|
||||
},
|
||||
"node_modules/discord-api-types": {
|
||||
"version": "0.37.4",
|
||||
"resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.4.tgz",
|
||||
@@ -1604,6 +1626,14 @@
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/kareem": {
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmjs.org/kareem/-/kareem-2.5.1.tgz",
|
||||
"integrity": "sha512-7jFxRVm+jD+rkq3kY0iZDJfsO2/t4BBPeEb2qKn2lR/9KhuksYk5hxzfRYWMPV8P/x2d0kHD306YyWLzjjH+uA==",
|
||||
"engines": {
|
||||
"node": ">=12.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/kuler": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/kuler/-/kuler-2.0.0.tgz",
|
||||
@@ -1675,6 +1705,86 @@
|
||||
"whatwg-url": "^11.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/mongoose": {
|
||||
"version": "7.0.1",
|
||||
"resolved": "https://registry.npmjs.org/mongoose/-/mongoose-7.0.1.tgz",
|
||||
"integrity": "sha512-fxm2bPRG457Hb8RLwN8cMCokK8HNem/7g+qp5SrHC7Pt4Z4jqn1+/3cuc8W7uqehKDWEtpirggI7uw08x2ZIjQ==",
|
||||
"dependencies": {
|
||||
"bson": "^5.0.1",
|
||||
"kareem": "2.5.1",
|
||||
"mongodb": "5.1.0",
|
||||
"mpath": "0.9.0",
|
||||
"mquery": "5.0.0",
|
||||
"ms": "2.1.3",
|
||||
"sift": "16.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/mongoose"
|
||||
}
|
||||
},
|
||||
"node_modules/mongoose/node_modules/bson": {
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/bson/-/bson-5.0.1.tgz",
|
||||
"integrity": "sha512-y09gBGusgHtinMon/GVbv1J6FrXhnr/+6hqLlSmEFzkz6PodqF6TxjyvfvY3AfO+oG1mgUtbC86xSbOlwvM62Q==",
|
||||
"engines": {
|
||||
"node": ">=14.20.1"
|
||||
}
|
||||
},
|
||||
"node_modules/mongoose/node_modules/mongodb": {
|
||||
"version": "5.1.0",
|
||||
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-5.1.0.tgz",
|
||||
"integrity": "sha512-qgKb7y+EI90y4weY3z5+lIgm8wmexbonz0GalHkSElQXVKtRuwqXuhXKccyvIjXCJVy9qPV82zsinY0W1FBnJw==",
|
||||
"dependencies": {
|
||||
"bson": "^5.0.1",
|
||||
"mongodb-connection-string-url": "^2.6.0",
|
||||
"socks": "^2.7.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.20.1"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"saslprep": "^1.0.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@aws-sdk/credential-providers": "^3.201.0",
|
||||
"mongodb-client-encryption": "^2.3.0",
|
||||
"snappy": "^7.2.2"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@aws-sdk/credential-providers": {
|
||||
"optional": true
|
||||
},
|
||||
"mongodb-client-encryption": {
|
||||
"optional": true
|
||||
},
|
||||
"snappy": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/mpath": {
|
||||
"version": "0.9.0",
|
||||
"resolved": "https://registry.npmjs.org/mpath/-/mpath-0.9.0.tgz",
|
||||
"integrity": "sha512-ikJRQTk8hw5DEoFVxHG1Gn9T/xcjtdnOKIU1JTmGjZZlg9LST2mBLmcX3/ICIbgJydT2GOc15RnNy5mHmzfSew==",
|
||||
"engines": {
|
||||
"node": ">=4.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/mquery": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/mquery/-/mquery-5.0.0.tgz",
|
||||
"integrity": "sha512-iQMncpmEK8R8ncT8HJGsGc9Dsp8xcgYMVSbs5jgnm1lFHTZqMJTUWTDx1LBO8+mK3tPNZWFLBghQEIOULSTHZg==",
|
||||
"dependencies": {
|
||||
"debug": "4.x"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/ms": {
|
||||
"version": "2.1.3",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
|
||||
@@ -1875,6 +1985,11 @@
|
||||
"semver": "bin/semver"
|
||||
}
|
||||
},
|
||||
"node_modules/sift": {
|
||||
"version": "16.0.1",
|
||||
"resolved": "https://registry.npmjs.org/sift/-/sift-16.0.1.tgz",
|
||||
"integrity": "sha512-Wv6BjQ5zbhW7VFefWusVP33T/EM0vYikCaQ2qR8yULbsilAT8/wQaXvuQ3ptGLpoKx+lihJE3y2UTgKDyyNHZQ=="
|
||||
},
|
||||
"node_modules/simple-swizzle": {
|
||||
"version": "0.2.2",
|
||||
"resolved": "https://registry.npmjs.org/simple-swizzle/-/simple-swizzle-0.2.2.tgz",
|
||||
@@ -3290,6 +3405,21 @@
|
||||
"integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==",
|
||||
"dev": true
|
||||
},
|
||||
"debug": {
|
||||
"version": "4.3.4",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
|
||||
"integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==",
|
||||
"requires": {
|
||||
"ms": "2.1.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"ms": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
||||
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"discord-api-types": {
|
||||
"version": "0.37.4",
|
||||
"resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.4.tgz",
|
||||
@@ -3447,6 +3577,11 @@
|
||||
"resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz",
|
||||
"integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg=="
|
||||
},
|
||||
"kareem": {
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmjs.org/kareem/-/kareem-2.5.1.tgz",
|
||||
"integrity": "sha512-7jFxRVm+jD+rkq3kY0iZDJfsO2/t4BBPeEb2qKn2lR/9KhuksYk5hxzfRYWMPV8P/x2d0kHD306YyWLzjjH+uA=="
|
||||
},
|
||||
"kuler": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/kuler/-/kuler-2.0.0.tgz",
|
||||
@@ -3510,6 +3645,51 @@
|
||||
"whatwg-url": "^11.0.0"
|
||||
}
|
||||
},
|
||||
"mongoose": {
|
||||
"version": "7.0.1",
|
||||
"resolved": "https://registry.npmjs.org/mongoose/-/mongoose-7.0.1.tgz",
|
||||
"integrity": "sha512-fxm2bPRG457Hb8RLwN8cMCokK8HNem/7g+qp5SrHC7Pt4Z4jqn1+/3cuc8W7uqehKDWEtpirggI7uw08x2ZIjQ==",
|
||||
"requires": {
|
||||
"bson": "^5.0.1",
|
||||
"kareem": "2.5.1",
|
||||
"mongodb": "5.1.0",
|
||||
"mpath": "0.9.0",
|
||||
"mquery": "5.0.0",
|
||||
"ms": "2.1.3",
|
||||
"sift": "16.0.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"bson": {
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/bson/-/bson-5.0.1.tgz",
|
||||
"integrity": "sha512-y09gBGusgHtinMon/GVbv1J6FrXhnr/+6hqLlSmEFzkz6PodqF6TxjyvfvY3AfO+oG1mgUtbC86xSbOlwvM62Q=="
|
||||
},
|
||||
"mongodb": {
|
||||
"version": "5.1.0",
|
||||
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-5.1.0.tgz",
|
||||
"integrity": "sha512-qgKb7y+EI90y4weY3z5+lIgm8wmexbonz0GalHkSElQXVKtRuwqXuhXKccyvIjXCJVy9qPV82zsinY0W1FBnJw==",
|
||||
"requires": {
|
||||
"bson": "^5.0.1",
|
||||
"mongodb-connection-string-url": "^2.6.0",
|
||||
"saslprep": "^1.0.3",
|
||||
"socks": "^2.7.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"mpath": {
|
||||
"version": "0.9.0",
|
||||
"resolved": "https://registry.npmjs.org/mpath/-/mpath-0.9.0.tgz",
|
||||
"integrity": "sha512-ikJRQTk8hw5DEoFVxHG1Gn9T/xcjtdnOKIU1JTmGjZZlg9LST2mBLmcX3/ICIbgJydT2GOc15RnNy5mHmzfSew=="
|
||||
},
|
||||
"mquery": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/mquery/-/mquery-5.0.0.tgz",
|
||||
"integrity": "sha512-iQMncpmEK8R8ncT8HJGsGc9Dsp8xcgYMVSbs5jgnm1lFHTZqMJTUWTDx1LBO8+mK3tPNZWFLBghQEIOULSTHZg==",
|
||||
"requires": {
|
||||
"debug": "4.x"
|
||||
}
|
||||
},
|
||||
"ms": {
|
||||
"version": "2.1.3",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
|
||||
@@ -3641,6 +3821,11 @@
|
||||
"integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==",
|
||||
"dev": true
|
||||
},
|
||||
"sift": {
|
||||
"version": "16.0.1",
|
||||
"resolved": "https://registry.npmjs.org/sift/-/sift-16.0.1.tgz",
|
||||
"integrity": "sha512-Wv6BjQ5zbhW7VFefWusVP33T/EM0vYikCaQ2qR8yULbsilAT8/wQaXvuQ3ptGLpoKx+lihJE3y2UTgKDyyNHZQ=="
|
||||
},
|
||||
"simple-swizzle": {
|
||||
"version": "0.2.2",
|
||||
"resolved": "https://registry.npmjs.org/simple-swizzle/-/simple-swizzle-0.2.2.tgz",
|
||||
|
||||
+2
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "dayz-armbands",
|
||||
"version": "5.0.0.1",
|
||||
"version": "5.0.0.3",
|
||||
"description": "A General Purpose Discord Bot for DayZ Servers.",
|
||||
"main": "index.js",
|
||||
"nodemonConfig": {
|
||||
@@ -23,6 +23,7 @@
|
||||
"discord.js": "^14.3.0",
|
||||
"dotenv": "^16.0.2",
|
||||
"mongodb": "^4.12.1",
|
||||
"mongoose": "^7.0.1",
|
||||
"winston": "^3.8.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -8,6 +8,7 @@ const path = require("path");
|
||||
const fs = require('fs');
|
||||
const { Readable } = require('stream');
|
||||
const { finished } = require('stream/promises');
|
||||
const readline = require('readline');
|
||||
|
||||
class DayzArmbands extends Client {
|
||||
|
||||
@@ -102,6 +103,19 @@ class DayzArmbands extends Client {
|
||||
const stream = fs.createWriteStream('./logs/server-logs.ADM');
|
||||
const { body } = await fetch(res.data.token.url);
|
||||
await finished(Readable.fromWeb(body).pipe(stream));
|
||||
|
||||
const fileStream = fs.createReadStream('./logs/server-logs.ADM');
|
||||
|
||||
const rl = readline.createInterface({
|
||||
input: fileStream,
|
||||
crlfDelay: Infinity
|
||||
});
|
||||
let lines = [];
|
||||
for await (const line of rl) { lines.push(line); }
|
||||
|
||||
const channel = this.channels.cache.get('993272430342721597');
|
||||
|
||||
channel.send({ content: lines[lines.length-1] });
|
||||
}
|
||||
|
||||
async connectMongo(mongoURI, dbo) {
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
const mongoose = require('mongoose');
|
||||
|
||||
let bankSchema = mongoose.Schema({
|
||||
banking: {
|
||||
userID: String,
|
||||
guilds: {}
|
||||
}
|
||||
});
|
||||
|
||||
bankSchema.methods.createBank = function (userID, guildID, startingBalance, cash) {
|
||||
this.banking.userID = userID;
|
||||
this.banking.guilds = {};
|
||||
this.banking.guilds[guildID] = {
|
||||
account: {
|
||||
balance: startingBalance,
|
||||
cash: cash,
|
||||
}
|
||||
};;
|
||||
};
|
||||
|
||||
/*
|
||||
This function is to add a new guild specific bank to an already existing
|
||||
bank document
|
||||
or
|
||||
can be used to reset a data back to default
|
||||
*/
|
||||
function addBank(guilds, guildID, userID, client, startingBalance) {
|
||||
let updatedGuilds = guilds;
|
||||
updatedGuilds[guildID] = {
|
||||
account: {
|
||||
balance: startingBalance,
|
||||
cash: 0.00,
|
||||
}
|
||||
}
|
||||
|
||||
client.dbo.collection("banks").updateOne({"banking.userID":userID}, {$set: {"banking.guilds": updatedGuilds}}, function(err, res) {
|
||||
if (err) return false
|
||||
})
|
||||
return true
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
Bank: mongoose.model('Bank', bankSchema),
|
||||
addBank: addBank,
|
||||
};
|
||||
@@ -0,0 +1,47 @@
|
||||
const mongoose = require('mongoose');
|
||||
|
||||
let userSchema = mongoose.Schema({
|
||||
user: {
|
||||
userID: String,
|
||||
guilds: {}
|
||||
},
|
||||
});
|
||||
|
||||
userSchema.methods.createUser = function (userID, guildID, startingBalance, cash) {
|
||||
this.user.userID = userID;
|
||||
this.user.guilds = {};
|
||||
this.user.guilds[guildID] = {
|
||||
bankAccount: {
|
||||
balance: startingBalance,
|
||||
cash: cash,
|
||||
},
|
||||
faction: "",
|
||||
gamertag: ""
|
||||
};
|
||||
};
|
||||
|
||||
/*
|
||||
This function is to add a new guild specific user to an already existing
|
||||
user document
|
||||
or
|
||||
can be used to reset a data back to default
|
||||
*/
|
||||
function addUser(guilds, guildID, userID, client, startingBalance) {
|
||||
let updatedGuilds = guilds;
|
||||
updatedGuilds[guildID] = {
|
||||
bankAccount: {
|
||||
balance: startingBalance,
|
||||
cash: 0.00,
|
||||
}
|
||||
}
|
||||
|
||||
client.dbo.collection("users").updateOne({"user.userID":userID}, {$set: {"user.guilds": updatedGuilds}}, function(err, res) {
|
||||
if (err) return false
|
||||
})
|
||||
return true
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
User: mongoose.model('User', userSchema),
|
||||
addUser: addUser,
|
||||
};
|
||||
Reference in new issue
Block a user