change/simplify err function handles

This commit is contained in:
SowinskiBraeden authored and GitHub committed 2023-09-04 10:52:16 -07:00
1 parent cbdbd18051
commit 317c48de36
19 files changed
+61 -61

No files matched your search

+4 -4
View File
@@ -168,7 +168,7 @@ module.exports = {
$set: {
"server.playerstats": []
}
}, function (err, res) {
}, (err, res) => {
if (err) return client.sendInternalError(interaction, err);
});
}
@@ -232,7 +232,7 @@ module.exports = {
$set: {
"server.playerstats": []
}
}, function (err, res) {
}, (err, res) => {
if (err) return client.sendInternalError(interaction, err);
});
}
@@ -333,7 +333,7 @@ module.exports = {
$set: {
'server.playerstats': GuildDB.playerstats,
}
}, function(err, res) {
}, (err, res) => {
if (err) return client.sendInternalError(interaction, err);
});
@@ -396,7 +396,7 @@ module.exports = {
? banking.guilds[GuildDB.serverID].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}.balance`]:newBalance}}, function(err, res) {
client.dbo.collection("users").updateOne({"user.userID":targetUserID},{$set:{[`user.guilds.${GuildDB.serverID}.balance`]:newBalance}}, (err, res) => {
if (err) return client.sendInternalError(interaction, err);
});
+8 -8
View File
@@ -220,7 +220,7 @@ module.exports = {
$push: {
'server.alarms': alarm,
}
}, function (err, res) {
}, (err, res) => {
if (err) return client.sendInternalError(interaction, err);
});
@@ -406,7 +406,7 @@ module.exports = {
$pull: {
'server.alarms': alarm,
}
}, function (err, res) {
}, (err, res) => {
if (err) return client.sendInternalError(interaction, err);
});
@@ -452,7 +452,7 @@ module.exports = {
$set: {
'server.alarms': GuildDB.alarms,
}
}, function (err, res) {
}, (err, res) => {
if (err) return client.sendInternalError(interaction, err);
});
@@ -484,7 +484,7 @@ module.exports = {
$set: {
'server.alarms': GuildDB.alarms,
}
}, function (err, res) {
}, (err, res) => {
if (err) return client.sendInternalError(interaction, err);
});
@@ -536,7 +536,7 @@ module.exports = {
$set: {
'server.alarms': GuildDB.alarms,
}
}, function (err, res) {
}, (err, res) => {
if (err) return client.sendInternalError(interaction, err);
});
@@ -566,7 +566,7 @@ module.exports = {
$set: {
'server.alarms': GuildDB.alarms,
}
}, function (err, res) {
}, (err, res) => {
if (err) return client.sendInternalError(interaction, err);
});
@@ -597,7 +597,7 @@ module.exports = {
$set: {
'server.alarms': GuildDB.alarms,
}
}, function (err, res) {
}, (err, res) => {
if (err) return client.sendInternalError(interaction, err);
});
@@ -628,7 +628,7 @@ module.exports = {
$set: {
'server.alarms': GuildDB.alarms,
}
}, function (err, res) {
}, (err, res) => {
if (err) return client.sendInternalError(interaction, err);
});
+2 -2
View File
@@ -155,7 +155,7 @@ module.exports = {
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}.balance`]:newBalance}}, function(err, res) {
client.dbo.collection("users").updateOne({"user.userID":interaction.member.user.id},{$set:{[`user.guilds.${GuildDB.serverID}.balance`]:newBalance}}, (err, res) => {
if (err) return client.sendInternalError(interaction, err);
});
@@ -181,7 +181,7 @@ module.exports = {
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}.balance`]:newTargetBalance}}, function(err, res) {
client.dbo.collection("users").updateOne({"user.userID":targetUserID},{$set:{[`user.guilds.${GuildDB.serverID}.balance`]:newTargetBalance}}, (err, res) => {
if (err) return client.sendInternalError(interaction, err);
});
+4 -4
View File
@@ -104,7 +104,7 @@ module.exports = {
$set: {
[`user.guilds.${GuildDB.serverID}.balance`]: newBalance,
}
}, function(err, res) {
}, (err, res) => {
if (err) return client.sendInternalError(interaction, err);
});
@@ -121,7 +121,7 @@ module.exports = {
$set: {
'server.playerstats': GuildDB.playerstats,
}
}, function(err, res) {
}, (err, res) => {
if (err) return client.sendInternalError(interaction, err);
});
@@ -162,7 +162,7 @@ module.exports = {
const newBalance = banking.guilds[GuildDB.serverID].balance - (totalBounty * 2);
client.dbo.collection("users").updateOne({"user.userID":interaction.member.user.id},{$set:{[`user.guilds.${GuildDB.serverID}.balance`]:newBalance}}, function(err, res) {
client.dbo.collection("users").updateOne({"user.userID":interaction.member.user.id},{$set:{[`user.guilds.${GuildDB.serverID}.balance`]:newBalance}}, (err, res) => {
if (err) return client.sendInternalError(interaction, err);
});
@@ -173,7 +173,7 @@ module.exports = {
$set: {
'server.playerstats': GuildDB.playerstats,
}
}, function(err, res) {
}, (err, res) => {
if (err) return client.sendInternalError(interaction, err);
});
+2 -2
View File
@@ -129,12 +129,12 @@ module.exports = {
for (const [fid, data] of Object.entries(GuildDB.factionArmbands)) {
if (fid == factionID) removeQuery = data.armband;
}
client.dbo.collection("guilds").updateOne({'server.serverID': GuildDB.serverID}, {$pull: {'server.usedArmbands': removeQuery}}, function (err, res) {
client.dbo.collection("guilds").updateOne({'server.serverID': GuildDB.serverID}, {$pull: {'server.usedArmbands': removeQuery}}, (err, res) => {
if (err) return client.sendInternalError(interaction, err);
})
}
client.dbo.collection("guilds").updateOne({'server.serverID': GuildDB.serverID}, query, function (err, res) {
client.dbo.collection("guilds").updateOne({'server.serverID': GuildDB.serverID}, query, (err, res) => {
if (err) return client.sendInternalError(interaction, err);
})
+1 -1
View File
@@ -89,7 +89,7 @@ module.exports = {
newData.balance += totalIncome;
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}}, (err, res) => {
if (err) return client.sendInternalError(interaction, err);
});
+22 -22
View File
@@ -349,7 +349,7 @@ module.exports = {
if (channelAdd.type=="voice") {error=true;newChannelErrorEmbed.setDescription(`**Error Notice:** Cannot add voice channel to allowed channels.`);}
if (error) return interaction.send({ embeds: [newChannelErrorEmbed] });
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$push:{"server.allowedChannels": channelid}}, function (err, res) {
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$push:{"server.allowedChannels": channelid}}, (err, res) => {
if (err) return client.sendInternalError(interaction, err);
});
@@ -390,7 +390,7 @@ module.exports = {
if (args[0].options[0].value == 'add') {
const botAdminRoleId = args[0].options[1].value;
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$push: {"server.botAdminRoles": botAdminRoleId}}, function(err, res) {
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$push: {"server.botAdminRoles": botAdminRoleId}}, (err, res) => {
if (err) return client.sendInternalError(interaction, err);
});
@@ -430,7 +430,7 @@ module.exports = {
}
case 'admin_role':
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$set: {"server.adminRole": args[0].options[0].value}}, function(err, res) {
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$set: {"server.adminRole": args[0].options[0].value}}, (err, res) => {
if (err) return client.sendInternalError(interaction, err);
});
@@ -442,7 +442,7 @@ module.exports = {
case 'exclude':
if (args[0].options[0].value == 'add') {
client.dbo.collection('guilds').updateOne({'server.serverID': GuildDB.serverID}, {$push: {'server.excludedRoles': args[0].options[1].value}}, function(err, res) {
client.dbo.collection('guilds').updateOne({'server.serverID': GuildDB.serverID}, {$push: {'server.excludedRoles': args[0].options[1].value}}, (err, res) => {
if (err) return client.sendInternalError(interaction, err);
})
@@ -453,7 +453,7 @@ module.exports = {
return interaction.send({ embeds: [successExcludeEmbed] });
} else if (args[0].options[0].value == 'remove') {
client.dbo.collection('guilds').updateOne({'server.serverID': GuildDB.serverID}, {$pull: {'server.excludedRoles': args[0].options[1].value}}, function(err, res) {
client.dbo.collection('guilds').updateOne({'server.serverID': GuildDB.serverID}, {$pull: {'server.excludedRoles': args[0].options[1].value}}, (err, res) => {
if (err) return client.sendInternalError(interaction, err);
})
@@ -510,7 +510,7 @@ module.exports = {
case 'killfeed_channel':
const killfeedChannel = args[0].options[0].value;
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$set: {"server.killfeedChannel": killfeedChannel}}, function(err, res) {
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$set: {"server.killfeedChannel": killfeedChannel}}, (err, res) => {
if (err) return client.sendInternalError(interaction, err);
});
@@ -523,7 +523,7 @@ module.exports = {
case 'show_killfeed_coords':
const showKillfeedCoordsConfiguration = args[0].options[0].value;
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$set: {"server.showKillfeedCoords": showKillfeedCoordsConfiguration}}, function(err, res) {
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$set: {"server.showKillfeedCoords": showKillfeedCoordsConfiguration}}, (err, res) => {
if (err) return client.sendInternalError(interaction, err);
});
@@ -536,7 +536,7 @@ module.exports = {
case 'admin_logs_channel':
const adminLogsChannel = args[0].options[0].value;
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$set: {"server.connectionLogsChannel": adminLogsChannel}}, function(err, res) {
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$set: {"server.connectionLogsChannel": adminLogsChannel}}, (err, res) => {
if (err) return client.sendInternalError(interaction, err);
});
@@ -549,7 +549,7 @@ module.exports = {
case 'welcome_channel':
const welcomeChannel = args[0].options[0].value;
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$set: {"server.welcomeChannel": welcomeChannel}}, function(err, res) {
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$set: {"server.welcomeChannel": welcomeChannel}}, (err, res) => {
if (err) return client.sendInternalError(interaction, err);
});
@@ -562,7 +562,7 @@ module.exports = {
case 'active_players_channel':
const acticePlayersChannel = args[0].options[0].value;
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$set: {"server.activePlayersChannel": acticePlayersChannel}}, function(err, res) {
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$set: {"server.activePlayersChannel": acticePlayersChannel}}, (err, res) => {
if (err) return client.sendInternalError(interaction, err);
});
@@ -575,7 +575,7 @@ module.exports = {
case 'linked_gt_role':
const linked_gt_role = args[0].options[0].value;
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$set: {"server.linkedGamertagRole": linked_gt_role}}, function(err, res) {
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$set: {"server.linkedGamertagRole": linked_gt_role}}, (err, res) => {
if (err) return client.sendInternalError(interaction, err);
});
@@ -588,7 +588,7 @@ module.exports = {
case 'member_role':
const member_role = args[0].options[0].value;
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$set: {"server.memberRole": member_role}}, function(err, res) {
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$set: {"server.memberRole": member_role}}, (err, res) => {
if (err) return client.sendInternalError(interaction, err);
});
@@ -599,7 +599,7 @@ module.exports = {
return interaction.send({ embeds: [successMemberRoleEmbed] });
case 'starting_balance':
client.dbo.collection("guilds").updateOne({"server.serverID": GuildDB.serverID}, {$set: {"server.startingBalance":args[0].options[0].value}}, function(err, res) {
client.dbo.collection("guilds").updateOne({"server.serverID": GuildDB.serverID}, {$set: {"server.startingBalance":args[0].options[0].value}}, (err, res) => {
if (err) return client.sendInternalError(interaction, err);
});
@@ -628,7 +628,7 @@ module.exports = {
income: args[0].options[0].options[1].value,
}
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$push: {"server.incomeRoles":newIncome}}, function(err, res) {
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$push: {"server.incomeRoles":newIncome}}, (err, res) => {
if (err) return client.sendInternalError(interaction, err);
});
} else {
@@ -640,7 +640,7 @@ module.exports = {
$set: {
"server.incomeRoles.$.income": args[0].options[0].options[1].value
}
}, function(err, res) {
}, (err, res) => {
if (err) return client.sendInternalError(interaction, err);
});
}
@@ -682,7 +682,7 @@ module.exports = {
}
case 'income_limiter':
client.dbo.collection("guilds").updateOne({"server.serverID": GuildDB.serverID}, {$set: {"server.incomeLimiter":args[0].options[0].value}}, function(err, res) {
client.dbo.collection("guilds").updateOne({"server.serverID": GuildDB.serverID}, {$set: {"server.incomeLimiter":args[0].options[0].value}}, (err, res) => {
if (err) return client.sendInternalError(interaction, err);
});
@@ -693,7 +693,7 @@ module.exports = {
return interaction.send({ embeds: [successIncomeLimiterEmbed] });
case 'uav-price':
client.dbo.collection("guilds").updateOne({"server.serverID": GuildDB.serverID}, {$set: {"server.uavPrice":args[0].options[0].value}}, function(err, res) {
client.dbo.collection("guilds").updateOne({"server.serverID": GuildDB.serverID}, {$set: {"server.uavPrice":args[0].options[0].value}}, (err, res) => {
if (err) return client.sendInternalError(interaction, err);
});
@@ -704,7 +704,7 @@ module.exports = {
return interaction.send({ embeds: [successUAVPriceEmbed] });
case 'emp-price':
client.dbo.collection("guilds").updateOne({"server.serverID": GuildDB.serverID}, {$set: {"server.empPrice":args[0].options[0].value}}, function(err, res) {
client.dbo.collection("guilds").updateOne({"server.serverID": GuildDB.serverID}, {$set: {"server.empPrice":args[0].options[0].value}}, (err, res) => {
if (err) return client.sendInternalError(interaction, err);
});
@@ -733,7 +733,7 @@ module.exports = {
let action = ''
if (interaction.customId.split('-')[1]=='yes') {
action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$pull:{"server.allowedChannels": channelid}}, function (err, res) {
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$pull:{"server.allowedChannels": channelid}}, (err, res) => {
if (err) return client.sendInternalError(interaction, err);
});
} else if (interaction.customId.split('-')[1]=='no') action = 'kept';
@@ -758,7 +758,7 @@ module.exports = {
let roleId = interaction.customId.split('-')[2];
if (interaction.customId.split('-')[1]=='yes') {
action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$pull: {"server.botAdminRoles": roleId}}, function(err, res) {
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$pull: {"server.botAdminRoles": roleId}}, (err, res) => {
if (err) return client.sendInternalError(interaction, err);
});
} else if (interaction.customId.split('-')[1]=='no') action = 'kept';
@@ -784,7 +784,7 @@ module.exports = {
if (interaction.customId.split('-')[1]=='yes') {
action = 'removed';
let income = GuildDB.incemeRoles.find((i) => i.role == roleId);
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$pull: {"server.incomeRoles": income}}, function(err, res) {
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$pull: {"server.incomeRoles": income}}, (err, res) => {
if (err) return client.sendInternalError(interaction, err);
});
} else if (interaction.customId.split('-')[1]=='no') action = 'kept';
@@ -809,7 +809,7 @@ module.exports = {
if (interaction.customId.split('-')[1]=='yes') {
action = 'reset';
const defaultGuildConfig = client.getDefaultSettings(GuildDB.serverID);
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$set: {"server": defaultGuildConfig}}, function(err, res) {
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$set: {"server": defaultGuildConfig}}, (err, res) => {
if (err) return client.sendInternalError(interaction, err);
});
} else if (interaction.customId.split('-')[1]=='no') action = 'kept';
+2 -2
View File
@@ -93,7 +93,7 @@ module.exports = {
$set: {
"server.events": events
}
}, function(err, res) {
}, (err, res) => {
if (err) return client.sendInternalError(interaction, err);
});
@@ -138,7 +138,7 @@ module.exports = {
$pull: {
'server.events': event,
}
}, function (err, res) {
}, (err, res) => {
if (err) return client.sendInternalError(interaction, err);
});
+1 -1
View File
@@ -33,7 +33,7 @@ module.exports = {
$set: {
"server.playerstats": []
}
}, function (err, res) {
}, (err, res) => {
if (err) return client.sendInternalError(interaction, err);
});
}
+1 -1
View File
@@ -26,7 +26,7 @@ module.exports = {
$set: {
"server.playerstats": []
}
}, function (err, res) {
}, (err, res) => {
if (err) return client.sendInternalError(interaction, err);
});
}
+1 -1
View File
@@ -27,7 +27,7 @@ module.exports = {
$set: {
"server.playerstats": []
}
}, function (err, res) {
}, (err, res) => {
if (err) return client.sendInternalError(interaction, err);
});
}
+1 -1
View File
@@ -51,7 +51,7 @@ module.exports = {
$set: {
"server.playerstats": []
}
}, function (err, res) {
}, (err, res) => {
if (err) return client.sendInternalError(interaction, err);
});
}
+2 -2
View File
@@ -63,7 +63,7 @@ module.exports = {
if (GuildDB.alarms.length == 0) return interaction.send({ embeds: [new EmbedBuilder().setColor(client.config.Colors.Default).setDescription('**Notice:** No Existing Alarms to EMP.')], flags: (1 << 6) });
client.dbo.collection("users").updateOne({"user.userID":interaction.member.user.id},{$set:{[`user.guilds.${GuildDB.serverID}.balance`]:newBalance}}, function(err, res) {
client.dbo.collection("users").updateOne({"user.userID":interaction.member.user.id},{$set:{[`user.guilds.${GuildDB.serverID}.balance`]:newBalance}}, (err, res) => {
if (err) return client.sendInternalError(interaction, err);
});
@@ -102,7 +102,7 @@ module.exports = {
$set: {
'server.alarms': alarms,
}
}, function (err, res) {
}, (err, res) => {
if (err) return client.sendInternalError(interaction, err);
});
+2 -2
View File
@@ -78,7 +78,7 @@ module.exports = {
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}.balance`]:newBalance}}, function(err, res) {
client.dbo.collection("users").updateOne({"user.userID":interaction.member.user.id},{$set:{[`user.guilds.${GuildDB.serverID}.balance`]:newBalance}}, (err, res) => {
if (err) return client.sendInternalError(interaction, err);
});
@@ -93,7 +93,7 @@ module.exports = {
$push: {
'server.uavs': uav,
}
}, function (err, res) {
}, (err, res) => {
if (err) return client.sendInternalError(interaction, err);
});