fix banking db calls, add permission check for settings command
This commit is contained in:
8 files changed
+79
-51
No files matched your search
+12
-12
@@ -111,7 +111,7 @@ module.exports = {
|
||||
return interaction.send(`You are not allowed to use the bot in this channel.`);
|
||||
}
|
||||
|
||||
let banking = await client.dbo.collection("banking").findOne({"account.userID": interaction.member.user.id}).then(banking => banking);
|
||||
let banking = await client.dbo.collection("banks").findOne({"account.userID": interaction.member.user.id}).then(banking => banking);
|
||||
|
||||
if (!banking) {
|
||||
banking = {
|
||||
@@ -198,7 +198,7 @@ module.exports = {
|
||||
newBalance = banking.guilds[guildDB.serverID].account.balance + args[0].options[0].value;
|
||||
newCash = Math.abs(banking.guilds[guildDB.serverID].account.cash.toFixed(2) - args[0].options[0].value);
|
||||
|
||||
client.dbo.collection("banking").updateOne({"account.userID":interaction.member.user.id},{$set:{[`banking.guilds.${guildDB.serverID}.account.balance`]:newBalance,[`banking.guilds.${guildDB.serverID}.account.cash`]:newCash}}, function(err, res) {
|
||||
client.dbo.collection("banks").updateOne({"account.userID":interaction.member.user.id},{$set:{[`banking.guilds.${guildDB.serverID}.account.balance`]:newBalance,[`banking.guilds.${guildDB.serverID}.account.cash`]:newCash}}, function(err, res) {
|
||||
if (err) {
|
||||
client.log(err);
|
||||
const embed = new MessageEmbed()
|
||||
@@ -239,7 +239,7 @@ module.exports = {
|
||||
newBalance = banking.guilds[guildDB.serverID].account.balance - args[0].options[0].value;
|
||||
newCash = banking.guilds[guildDB.serverID].account.cash + args[0].options[0].value;
|
||||
|
||||
client.dbo.collection("banking").updateOne({"account.userID":interaction.member.user.id},{$set:{[`banking.guilds.${guildDB.serverID}.account.balance`]:newBalance,[`banking.guilds.${guildDB.serverID}.account.cash`]:newCash}}, function(err, res) {
|
||||
client.dbo.collection("banks").updateOne({"account.userID":interaction.member.user.id},{$set:{[`banking.guilds.${guildDB.serverID}.account.balance`]:newBalance,[`banking.guilds.${guildDB.serverID}.account.cash`]:newCash}}, function(err, res) {
|
||||
if (err) {
|
||||
client.log(err);
|
||||
const embed = new MessageEmbed()
|
||||
@@ -276,7 +276,7 @@ module.exports = {
|
||||
// Show target users balance
|
||||
|
||||
let targetUserID = args[0].options[0].value.replace('<@!', '').replace('>', '');
|
||||
let targetUserBanking = await client.dbo.collection("banking").findOne({"account.userID": targetUserID}).then(banking => banking);
|
||||
let targetUserBanking = await client.dbo.collection("banks").findOne({"account.userID": targetUserID}).then(banking => banking);
|
||||
|
||||
if (!targetUserBanking) {
|
||||
banking = {
|
||||
@@ -353,7 +353,7 @@ module.exports = {
|
||||
|
||||
newCash = banking.guilds[guildDB.serverID].account.cash - args[0].options[1].value;
|
||||
|
||||
client.dbo.collection("banking").updateOne({"account.userID":interaction.member.user.id},{$set:{[`banking.guilds.${guildDB.serverID}.account.cash`]:newCash}}, function(err, res) {
|
||||
client.dbo.collection("banks").updateOne({"account.userID":interaction.member.user.id},{$set:{[`banking.guilds.${guildDB.serverID}.account.cash`]:newCash}}, function(err, res) {
|
||||
if (err) {
|
||||
client.log(err);
|
||||
const embed = new MessageEmbed()
|
||||
@@ -423,7 +423,7 @@ module.exports = {
|
||||
});
|
||||
|
||||
|
||||
let targetUserBanking = await client.dbo.collection("banking").findOne({"account.userID": targetUserID}).then(banking => banking);
|
||||
let targetUserBanking = await client.dbo.collection("banks").findOne({"account.userID": targetUserID}).then(banking => banking);
|
||||
|
||||
if (!targetUserBanking) {
|
||||
targetUserBanking = {
|
||||
@@ -434,7 +434,7 @@ module.exports = {
|
||||
}
|
||||
}
|
||||
|
||||
client.dbo.collection("banking").insertOne(targetUserBanking, function(err, res) {
|
||||
client.dbo.collection("banks").insertOne(targetUserBanking, function(err, res) {
|
||||
if (err) {
|
||||
client.log(err);
|
||||
const embed = new MessageEmbed()
|
||||
@@ -447,7 +447,7 @@ module.exports = {
|
||||
} else {
|
||||
let newTargetCash = targetUserBanking.account.cash + args[0].options[1].value;
|
||||
|
||||
client.dbo.collection("banking").updateOne({"account.userID": targetUserID}, {$set: {[`banking.guilds.${guildDB.serverID}.account.cash`]: newTargetCash}}, function(err, res) {
|
||||
client.dbo.collection("banks").updateOne({"account.userID": targetUserID}, {$set: {[`banking.guilds.${guildDB.serverID}.account.cash`]: newTargetCash}}, function(err, res) {
|
||||
if (err) {
|
||||
client.log(err);
|
||||
const embed = new MessageEmbed()
|
||||
@@ -479,7 +479,7 @@ module.exports = {
|
||||
|
||||
newBalance = banking.guilds[guildDB.serverID].account.balance - args[0].options[1].value;
|
||||
|
||||
client.dbo.collection("banking").updateOne({"account.userID":interaction.member.user.id},{$set:{[`banking.guilds.${guildDB.serverID}.account.balance`]:newBalance}}, function(err, res) {
|
||||
client.dbo.collection("banks").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()
|
||||
@@ -491,7 +491,7 @@ module.exports = {
|
||||
});
|
||||
|
||||
let targetUserID = args[0].options[0].value.replace('<@!', '').replace('>', '');
|
||||
let targetUserBanking = await client.dbo.collection("banking").findOne({"account.userID": targetUserID}).then(banking => banking);
|
||||
let targetUserBanking = await client.dbo.collection("banks").findOne({"account.userID": targetUserID}).then(banking => banking);
|
||||
|
||||
if (!targetUserBanking) {
|
||||
targetUserBanking = {
|
||||
@@ -502,7 +502,7 @@ module.exports = {
|
||||
}
|
||||
}
|
||||
|
||||
client.dbo.collection("banking").insertOne(targetUserBanking, function(err, res) {
|
||||
client.dbo.collection("banks").insertOne(targetUserBanking, function(err, res) {
|
||||
if (err) {
|
||||
client.log(err);
|
||||
const embed = new MessageEmbed()
|
||||
@@ -515,7 +515,7 @@ module.exports = {
|
||||
} else {
|
||||
let newTargetBalance = targetUserBanking.account.balance + args[0].options[1].value;
|
||||
|
||||
client.dbo.collection("banking").updateOne({"account.userID":targetUserID},{$set:{[`banking.guilds.${guildDB.serverID}.account.balance`]:newTargetBalance}}, function(err, res) {
|
||||
client.dbo.collection("banks").updateOne({"account.userID":targetUserID},{$set:{[`banking.guilds.${guildDB.serverID}.account.balance`]:newTargetBalance}}, function(err, res) {
|
||||
if (err) {
|
||||
client.log(err);
|
||||
const embed = new MessageEmbed()
|
||||
|
||||
Reference in new issue
Block a user