7.0.0 EMP feature
This commit is contained in:
6 files changed
+124
-4
No files matched your search
@@ -213,6 +213,7 @@ module.exports = {
|
|||||||
empExempt: client.exists(args[0].options[6]) ? args[0].options[6].value : false,
|
empExempt: client.exists(args[0].options[6]) ? args[0].options[6].value : false,
|
||||||
showPlayerCoord: client.exists(args[0].options[7]) ? args[0].options[7].value : true,
|
showPlayerCoord: client.exists(args[0].options[7]) ? args[0].options[7].value : true,
|
||||||
disabled: false,
|
disabled: false,
|
||||||
|
empExpire: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
client.dbo.collection('guilds').updateOne({ 'server.serverID': GuildDB.serverID }, {
|
client.dbo.collection('guilds').updateOne({ 'server.serverID': GuildDB.serverID }, {
|
||||||
|
|||||||
@@ -0,0 +1,117 @@
|
|||||||
|
const { EmbedBuilder, ActionRowBuilder, SelectMenuBuilder } = require('discord.js');
|
||||||
|
const { User, addUser } = require('../structures/user');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: "purchase-emp",
|
||||||
|
debug: false,
|
||||||
|
global: false,
|
||||||
|
description: "EMP an Alarm to prevent any updates for 30 minutes.",
|
||||||
|
usage: "",
|
||||||
|
permissions: {
|
||||||
|
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
|
||||||
|
member: ["MANAGE_GUILD"],
|
||||||
|
},
|
||||||
|
options: [],
|
||||||
|
SlashCommand: {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {require("../structures/QuarksBot")} client
|
||||||
|
* @param {import("discord.js").Message} message
|
||||||
|
* @param {string[]} args
|
||||||
|
* @param {*} param3
|
||||||
|
*/
|
||||||
|
run: async (client, interaction, args, { GuildDB }) => {
|
||||||
|
|
||||||
|
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]: {
|
||||||
|
bankAccount: {
|
||||||
|
balance: GuildDB.startingBalance,
|
||||||
|
cash: 0.00,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Register bank for user
|
||||||
|
let newBank = new User();
|
||||||
|
newBank.createUser(interaction.member.user.id, GuildDB.serverID, GuildDB.startingBalance, 0);
|
||||||
|
newBank.save().catch(err => {
|
||||||
|
if (err) return client.sendInternalError(interaction, err);
|
||||||
|
});
|
||||||
|
|
||||||
|
} else banking = banking.user;
|
||||||
|
|
||||||
|
if (!client.exists(banking.guilds[GuildDB.serverID])) {
|
||||||
|
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 (banking.guilds[GuildDB.serverID].balance.toFixed(2) - GuildDB.empPrice < 0) {
|
||||||
|
let embed = new EmbedBuilder()
|
||||||
|
.setTitle('**Bank Notice:** NSF. Non sufficient funds')
|
||||||
|
.setColor(client.config.Colors.Red);
|
||||||
|
|
||||||
|
return interaction.send({ embeds: [embed], flags: (1 << 6) });
|
||||||
|
}
|
||||||
|
|
||||||
|
const newBalance = banking.guilds[GuildDB.serverID].balance - GuildDB.empPrice;
|
||||||
|
|
||||||
|
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) {
|
||||||
|
if (err) return client.sendInternalError(interaction, err);
|
||||||
|
});
|
||||||
|
|
||||||
|
let alarms = new SelectMenuBuilder()
|
||||||
|
.setCustomId(`EMPAlarmSelect-${interaction.member.user.id}`)
|
||||||
|
.setPlaceholder(`Select an Alarm to EMP.`)
|
||||||
|
|
||||||
|
for (let i = 0; i < GuildDB.alarms.length; i++) {
|
||||||
|
if (!alarm.empExempt) {
|
||||||
|
alarms.addOptions({
|
||||||
|
label: GuildDB.alarms[i].name,
|
||||||
|
description: `EMP this Alarm for $500,000`,
|
||||||
|
value: GuildDB.alarms[i].name
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const opt = new ActionRowBuilder().addComponents(alarms);
|
||||||
|
|
||||||
|
return interaction.send({ components: [opt], flags: (1 << 6) });
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
Interactions: {
|
||||||
|
EMPAlarmSelect: {
|
||||||
|
run: async (client, interaction, GuildDB) => {
|
||||||
|
let alarm = GuildDB.alarms.find(alarm => alarm.name == interaction.values[0]);
|
||||||
|
let alarms = GuildDB.alarms;
|
||||||
|
let alarmIndex = alarms.indexOf(alarm);
|
||||||
|
alarm.disabled = true;
|
||||||
|
let d = new Date();
|
||||||
|
alarm.empExpire = new Date(d.getTime() += (30 * 60 * 1000));
|
||||||
|
alarms[alarmIndex] = alarm;
|
||||||
|
|
||||||
|
client.dbo.collection('guilds').updateOne({ 'server.serverID': GuildDB.serverID }, {
|
||||||
|
$set: {
|
||||||
|
'server.alarms': alarms,
|
||||||
|
}
|
||||||
|
}, function (err, res) {
|
||||||
|
if (err) return client.sendInternalError(interaction, err);
|
||||||
|
});
|
||||||
|
|
||||||
|
let successEmbed = new EmbedBuilder()
|
||||||
|
.setColor(client.config.Colors.Green)
|
||||||
|
.setDescription(`**Success:** Successfully EMP'd **${alarm.name}** for 30 minutes.`);
|
||||||
|
|
||||||
|
return interaction.update({ embeds: [successEmbed], components: [] });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,7 +6,7 @@ module.exports = {
|
|||||||
debug: false,
|
debug: false,
|
||||||
global: false,
|
global: false,
|
||||||
description: "Send a UAV to scout for 30 minutes. (500m range)",
|
description: "Send a UAV to scout for 30 minutes. (500m range)",
|
||||||
usage: "[cmd] [opt]",
|
usage: "[x-coord] [y-coord]",
|
||||||
permissions: {
|
permissions: {
|
||||||
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
|
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
|
||||||
member: ["MANAGE_GUILD"],
|
member: ["MANAGE_GUILD"],
|
||||||
@@ -73,7 +73,7 @@ module.exports = {
|
|||||||
.setTitle('**Bank Notice:** NSF. Non sufficient funds')
|
.setTitle('**Bank Notice:** NSF. Non sufficient funds')
|
||||||
.setColor(client.config.Colors.Red);
|
.setColor(client.config.Colors.Red);
|
||||||
|
|
||||||
return interaction.send({ embeds: [embed] });
|
return interaction.send({ embeds: [embed], flags: (1 << 6) });
|
||||||
}
|
}
|
||||||
|
|
||||||
const newBalance = banking.guilds[GuildDB.serverID].balance - GuildDB.uavPrice;
|
const newBalance = banking.guilds[GuildDB.serverID].balance - GuildDB.uavPrice;
|
||||||
@@ -102,7 +102,6 @@ module.exports = {
|
|||||||
.setDescription(`**Success:** Successfully deployed a UAV to **[${uav.origin[0]}, ${uav.origin[1]}](https://www.izurvive.com/chernarusplussatmap/#location=${uav.origin[0]};${uav.origin[1]})**\nRange: 500m`);
|
.setDescription(`**Success:** Successfully deployed a UAV to **[${uav.origin[0]}, ${uav.origin[1]}](https://www.izurvive.com/chernarusplussatmap/#location=${uav.origin[0]};${uav.origin[1]})**\nRange: 500m`);
|
||||||
|
|
||||||
return interaction.send({ embeds: [successEmbed], flags: (1 << 6) });
|
return interaction.send({ embeds: [successEmbed], flags: (1 << 6) });
|
||||||
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "dayz-armbands",
|
"name": "dayz-armbands",
|
||||||
"version": "6.14.2",
|
"version": "7.0.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": {
|
||||||
|
|||||||
@@ -356,6 +356,7 @@ class DayzArmbands extends Client {
|
|||||||
linkedGamertagRole: "",
|
linkedGamertagRole: "",
|
||||||
startingBalance: 500,
|
startingBalance: 500,
|
||||||
uavPrice: 50000,
|
uavPrice: 50000,
|
||||||
|
empPrice: 500000,
|
||||||
memberRole: "",
|
memberRole: "",
|
||||||
adminRole: "",
|
adminRole: "",
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ module.exports = {
|
|||||||
|
|
||||||
for (let i = 0; i < guild.alarms.length; i++) {
|
for (let i = 0; i < guild.alarms.length; i++) {
|
||||||
let alarm = guild.alarms[i];
|
let alarm = guild.alarms[i];
|
||||||
|
let now = new Date();
|
||||||
|
if (alarm.uavExpire!=null&&alarm.uavExpire<now) alarm.disabled = false;
|
||||||
if (alarm.disabled) continue; // ignore if alarm is disabled due to emp
|
if (alarm.disabled) continue; // ignore if alarm is disabled due to emp
|
||||||
if (alarm.ignoredPlayers.includes(data.playerID)) continue;
|
if (alarm.ignoredPlayers.includes(data.playerID)) continue;
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user