From 71cd1808d9c7ff29a0d1fa6a3aba692c03f3004c Mon Sep 17 00:00:00 2001 From: SowinskiBraeden Date: Thu, 26 Mar 2026 10:12:45 -0700 Subject: [PATCH] auto clean whitespace --- bot.js | 2 +- commands/admin.js | 2 +- commands/alarm.js | 30 +- commands/armbands.js | 8 +- commands/bank.js | 8 +- commands/bounty.js | 22 +- commands/claim.js | 18 +- commands/collect-income.js | 10 +- commands/compare-rating.js | 8 +- commands/config.js | 2286 ++++++++++++++++----------------- commands/event.js | 10 +- commands/factions.js | 10 +- commands/gamertag-link.js | 12 +- commands/gamertag-unlink.js | 8 +- commands/help.js | 24 +- commands/leaderboard.js | 44 +- commands/location.js | 8 +- commands/lookup.js | 12 +- commands/player-list.js | 8 +- commands/player-stats.js | 48 +- commands/purchase-emp.js | 10 +- commands/purchase-uav.js | 4 +- commands/reset.js | 8 +- commands/server.js | 24 +- commands/weapon-stats.js | 16 +- config/config.js | 2 +- database/destinations.js | 188 +-- database/player.js | 8 +- database/weapons.js | 4 +- events/guildCreate.js | 2 +- events/interactionCreate.js | 4 +- util/AdminLogsHandler.js | 6 +- util/AlarmsHandler.js | 20 +- util/CommandOptionTypes.js | 2 +- util/Cryptic.js | 2 +- util/Logger.js | 2 +- util/RegisterSlashCommands.js | 6 +- util/Vector.js | 6 +- 38 files changed, 1446 insertions(+), 1446 deletions(-) diff --git a/bot.js b/bot.js index 3856eaa..efb66e8 100644 --- a/bot.js +++ b/bot.js @@ -13,7 +13,7 @@ process.on('uncaughtException', async (error) => { // Asynchronously write the error message to a log file using Promises await new Promise((resolve, reject) => { if (HandleActivePlayersList.lastSendMessage) HandleActivePlayersList.lastSendMessage.delete().catch(error => client.sendError(channel, `HandleActivePlayersList Error: \n${error}`)); // Remove previous embed message before closing - fs.appendFile(path.join(__dirname, "./logs/Logs.log"), + fs.appendFile(path.join(__dirname, "./logs/Logs.log"), `{"level":"error","message":"${d.getHours()}:${d.getMinutes()} - ${d.getMonth()+1}:${d.getDate()}:${d.getFullYear()} | uncaughtException: ${error.stack}"}`, (logErr) => { if (logErr) { console.error('Error writing uncaughtException to log file:', logErr); diff --git a/commands/admin.js b/commands/admin.js index 98dfa54..8df98a5 100644 --- a/commands/admin.js +++ b/commands/admin.js @@ -409,4 +409,4 @@ module.exports = { } } -} \ No newline at end of file +} diff --git a/commands/alarm.js b/commands/alarm.js index 5aaa9cd..582fa75 100644 --- a/commands/alarm.js +++ b/commands/alarm.js @@ -15,11 +15,11 @@ const generateAlarmMenus = (alarms, customId, placeholder, description) => { currentAlarmComponents.addOptions({ label: alarm.name, description: description, - value: alarm.name, + value: alarm.name, }); }); alarmComponents.push(new ActionRowBuilder().addComponents(currentAlarmComponents)); - id++; + id++; } return alarmComponents; @@ -34,7 +34,7 @@ module.exports = { permissions: { channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"], member: ["MANAGE_GUILD"], - }, + }, options: [ { name: "create", @@ -229,7 +229,7 @@ module.exports = { * @param {string[]} args * @param {*} param3 */ - run: async (client, interaction, args, { GuildDB }) => { + run: async (client, interaction, args, { GuildDB }) => { const permissions = bitfieldCalculator.permissions(interaction.member.permissions); let canUseCommand = false; @@ -293,9 +293,9 @@ module.exports = { return interaction.send({ components: alarmComponents, flags: (1 << 6) }); } else if (args[0].name == 'add-player' || args[0].name == 'remove-player') { - + const add = args[0].name == 'add-player'; - + if (GuildDB.alarms.length == 0) return interaction.send({ embeds: [new EmbedBuilder().setColor(client.config.Colors.Default).setDescription(`**Notice:** No Existing Alarms to ${add?'Add':'Remove'} Player ${add?'to':'from'}.`)] }); const alarmComponents = generateAlarmMenus( @@ -422,7 +422,7 @@ module.exports = { if (interaction.customId.split('-')[1] == 'yes') { let alarm = GuildDB.alarms.find(alarm => alarm.name == interaction.customId.split('-')[2]); - + client.dbo.collection('guilds').updateOne({ 'server.serverID': GuildDB.serverID }, { $pull: { 'server.alarms': alarm, @@ -430,17 +430,17 @@ module.exports = { }, (err, res) => { if (err) return client.sendInternalError(interaction, err); }); - + let successEmbed = new EmbedBuilder() .setColor(client.config.Colors.Green) .setDescription(`**Success:** Successfully Deleted **${interaction.customId.split('-')[2]}**`); - + return interaction.update({ embeds: [successEmbed], components: [] }); } else { let successEmbed = new EmbedBuilder() .setColor(client.config.Colors.Green) .setDescription(`The Zone Alarm **${interaction.customId.split('-')[2]}** will not be deleted.`); - + return interaction.update({ embeds: [successEmbed], components: []}); } } @@ -449,14 +449,14 @@ module.exports = { run: async(client, interaction, GuildDB) => { let alarm = GuildDB.alarms.find(alarm => alarm.name == interaction.values[0]); let alarmIndex = GuildDB.alarms.indexOf(alarm); - + let playerStat = await client.dbo.collection("players").findOne({"gamertag": interaction.customId.split('-')[2]}); if (!client.exists(playerStat)) return interaction.update({ embeds: [new EmbedBuilder().setColor(client.config.Colors.Yellow).setDescription('**Not Found** This player cannot be found, the gamertag may be incorrect or this player has not logged onto the server before.')], components: [] }); - + let add = interaction.customId.split('-')[1] == 'add'; if (add) alarm.ignoredPlayers.push(playerStat.playerID); - else alarm.ignoredPlayers = alarm.ignoredPlayers.filter((v) => { + else alarm.ignoredPlayers = alarm.ignoredPlayers.filter((v) => { return v != playerStat.playerID; }); @@ -514,7 +514,7 @@ module.exports = { value: alarm.rules[i] }); } - + const opt = new ActionRowBuilder().addComponents(alarmRules); return interaction.update({ components: [opt], flags: (1 << 6) }); @@ -642,5 +642,5 @@ module.exports = { return interaction.update({ embeds: [successEmbed], components: [] }); } } - } + } } diff --git a/commands/armbands.js b/commands/armbands.js index 10fb4d3..64360e6 100644 --- a/commands/armbands.js +++ b/commands/armbands.js @@ -22,12 +22,12 @@ module.exports = { */ run: async (client, interaction, args, { GuildDB }) => { if (GuildDB.customChannelStatus==true&&!GuildDB.allowedChannels.includes(interaction.channel_id)) - return interaction.send({ content: `You are not allowed to use the bot in this channel.`, flags: (1 << 6) }); - + return interaction.send({ content: `You are not allowed to use the bot in this channel.`, flags: (1 << 6) }); + let available = new StringSelectMenuBuilder() .setCustomId(`View-1-${interaction.member.user.id}`) .setPlaceholder('View an armband from list 1') - + let availableNext = new StringSelectMenuBuilder() .setCustomId(`View-2-${interaction.member.user.id}`) .setPlaceholder('View an armband from list 2') @@ -55,7 +55,7 @@ module.exports = { if (tracker > 25) { opt2 = new ActionRowBuilder().addComponents(availableNext); compList.push(opt2); - } + } return interaction.send({ components: compList, flags: (1 << 6) }); }, diff --git a/commands/bank.js b/commands/bank.js index ec150c1..2351905 100644 --- a/commands/bank.js +++ b/commands/bank.js @@ -64,7 +64,7 @@ module.exports = { } let banking = await client.dbo.collection("users").findOne({"user.userID": interaction.member.user.id}).then(banking => banking); - + if (!banking) { banking = await createUser(interaction.member.user.id, GuildDB.serverID, GuildDB.startingBalance, client) if (!client.exists(banking)) return client.sendInternalError(interaction, err); @@ -91,7 +91,7 @@ module.exports = { if (!client.exists(banking)) return client.sendInternalError(interaction, err); } targetUserBanking = targetUserBanking.user; - + if (!client.exists(targetUserBanking.guilds[GuildDB.serverID])) { const success = addUser(banking.guilds, GuildDB.serverID, targetUserID, client, GuildDB.startingBalance); if (!success) return client.sendInternalError(interaction, 'Failed to add bank'); @@ -141,7 +141,7 @@ module.exports = { if (!client.exists(banking)) return client.sendInternalError(interaction, err); } targetUserBanking = targetUserBanking.user; - + if (!client.exists(targetUserBanking.guilds[GuildDB.serverID])) { const success = addUser(banking.guilds, GuildDB.serverID, targetUserID, client, GuildDB.startingBalance); if (!success) return client.sendInternalError(interaction, 'Failed to add bank'); @@ -162,4 +162,4 @@ module.exports = { } }, }, -} \ No newline at end of file +} diff --git a/commands/bounty.js b/commands/bounty.js index 3e237d8..ae164d1 100644 --- a/commands/bounty.js +++ b/commands/bounty.js @@ -70,7 +70,7 @@ module.exports = { let banking; if (args[0].name == 'set' || args[0].name == 'pay') { banking = await client.dbo.collection("users").findOne({"user.userID": interaction.member.user.id}).then(banking => banking); - + if (!banking) { banking = await createUser(interaction.member.user.id, GuildDB.serverID, GuildDB.startingBalance, client) if (!client.exists(banking)) return client.sendInternalError(interaction, err); @@ -87,7 +87,7 @@ module.exports = { let playerStat = await client.dbo.collection("players").findOne({"gamertag": args[0].options[0].value}); if (!client.exists(playerStat)) return interaction.send({ embeds: [new EmbedBuilder().setColor(client.config.Colors.Yellow).setDescription('**Not Found** This player cannot be found, the gamertag may be incorrect or this player has not logged onto the server before for at least ` 5 minutes `.')] }); - + if (args[0].options[1].value > banking.guilds[GuildDB.serverID].balance) { let nsf = new EmbedBuilder() .setDescription('**Bank Notice:** NSF. Non sufficient funds') @@ -97,7 +97,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, @@ -115,24 +115,24 @@ module.exports = { playerStat.bountiesLength = playerStat.bounties.length; // Will ensure bounties length = # of bounties, even if bountiesLength does not exists in player stat. await UpdatePlayer(client, playerStat, interaction); - + const successEmbed = new EmbedBuilder() .setTitle('Success') .setDescription(`Successfully set a **$${args[0].options[1].value.toFixed(2).toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2})}** bounty on \` ${playerStat.gamertag} \`\nThis can be viewed using `) .setColor(client.config.Colors.Green); - + return interaction.send({ embeds: [successEmbed], flags: (1 << 6) }); } else if (args[0].name == 'pay') { let playerStat = await client.dbo.collection("players").findOne({"discordID": interaction.member.user.id}); if (!client.exists(playerStat)) return interaction.send({ embeds: [new EmbedBuilder().setColor(client.config.Colors.Yellow).setDescription('**Not Found** Your user ID could not be found, contact an Admin.')] }); - + if (playerStat.bounties.length == 0) { const noBounty = new EmbedBuilder() .setColor(client.config.Colors.Yellow) .setDescription(`You have no bounties to pay off.`) - + return interaction.send({ embeds: [noBounty] }); } @@ -150,14 +150,14 @@ module.exports = { } const newBalance = banking.guilds[GuildDB.serverID].balance - (totalBounty * 2); - + await 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); }); playerStat.bounties = []; playerStat.bountiesLength = 0; - + await UpdatePlayer(client, playerStat, interaction); const payedOff = new EmbedBuilder() @@ -171,7 +171,7 @@ module.exports = { const activeBounties = await client.dbo.collection("players").find({ "bountiesLength": { $gt: 0 } }).toArray(); - + let bountiesEmbed = new EmbedBuilder() .setColor(client.config.Colors.Default) .setDescription('**Active Boutnies**'); @@ -187,4 +187,4 @@ module.exports = { } }, }, -} \ No newline at end of file +} diff --git a/commands/claim.js b/commands/claim.js index bbe188e..7f2e9bc 100644 --- a/commands/claim.js +++ b/commands/claim.js @@ -52,7 +52,7 @@ module.exports = { const warnArmbadChange = new EmbedBuilder() .setColor(client.config.Colors.Yellow) .setDescription(`**Notice:**\n> The faction <@&${args[0].value}> already has an armband selected. Are you sure you would like to change this?`) - + const opt = new ActionRowBuilder() .addComponents( new ButtonBuilder() @@ -71,7 +71,7 @@ module.exports = { let available = new StringSelectMenuBuilder() .setCustomId(`Claim-${args[0].value}-1-${interaction.member.user.id}`) .setPlaceholder('Select an armband from list 1 to claim') - + let availableNext = new StringSelectMenuBuilder() .setCustomId(`Claim-${args[0].value}-2-${interaction.member.user.id}`) .setPlaceholder('Select an armband from list 2 to claim') @@ -98,7 +98,7 @@ module.exports = { if (tracker > 25) { opt2 = new ActionRowBuilder().addComponents(availableNext); compList.push(opt2); - } + } return interaction.send({ components: compList }); }, @@ -106,7 +106,7 @@ module.exports = { Interactions: { Claim: { run: async (client, interaction, GuildDB) => { - if (!interaction.customId.endsWith(interaction.member.user.id)) + if (!interaction.customId.endsWith(interaction.member.user.id)) return interaction.reply({ content: 'This interaction is not for you', flags: (1 << 6) }); let factionID = interaction.customId.split('-')[1]; @@ -134,7 +134,7 @@ module.exports = { if (err) return client.sendInternalError(interaction, err); }) } - + client.dbo.collection("guilds").updateOne({'server.serverID': GuildDB.serverID}, query, (err, res) => { if (err) return client.sendInternalError(interaction, err); }) @@ -159,14 +159,14 @@ module.exports = { ChangeArmband: { run: async (client, interaction, GuildDB) => { - if (!interaction.customId.endsWith(interaction.member.user.id)) + if (!interaction.customId.endsWith(interaction.member.user.id)) return interaction.reply({ content: 'This interaction is not for you', flags: (1 << 6) }); if (interaction.customId.split('-')[1]=='yes') { let available = new StringSelectMenuBuilder() .setCustomId(`Claim-${interaction.customId.split('-')[2]}-update-1-${interaction.member.user.id}`) .setPlaceholder('Select an armband from list 1 to claim') - + let availableNext = new StringSelectMenuBuilder() .setCustomId(`Claim-${interaction.customId.split('-')[2]}-update-2-${interaction.member.user.id}`) .setPlaceholder('Select an armband from list 2 to claim') @@ -193,9 +193,9 @@ module.exports = { if (tracker > 25) { opt2 = new ActionRowBuilder().addComponents(availableNext); compList.push(opt2); - } + } - return interaction.update({ embeds: [], components: compList }); + return interaction.update({ embeds: [], components: compList }); } else { const cancel = new EmbedBuilder() diff --git a/commands/collect-income.js b/commands/collect-income.js index 02c9d41..defe3e7 100644 --- a/commands/collect-income.js +++ b/commands/collect-income.js @@ -22,7 +22,7 @@ module.exports = { */ run: async (client, interaction, args, { GuildDB }) => { if (GuildDB.customChannelStatus==true&&!GuildDB.allowedChannels.includes(interaction.channel_id)) { - return interaction.send({ content: `You are not allowed to use the bot in this channel.`, flags: (1 << 6) }); + return interaction.send({ content: `You are not allowed to use the bot in this channel.`, flags: (1 << 6) }); } const hasIncomeRole = GuildDB.incomeRoles.some(data => { @@ -41,7 +41,7 @@ module.exports = { let banking = await client.dbo.collection("users").findOne({"user.userID": interaction.member.user.id}).then(banking => banking); - + if (!banking) { banking = await createUser(interaction.member.user.id, GuildDB.serverID, GuildDB.startingBalance, client) if (!client.exists(banking)) return client.sendInternalError(interaction, err); @@ -54,7 +54,7 @@ module.exports = { } if (!client.exists(banking.guilds[GuildDB.serverID].lastIncome)) banking.guilds[GuildDB.serverID].lastIncome = new Date('2000-01-01T00:00:00'); - + let now = new Date(); let diff = (now - banking.guilds[GuildDB.serverID].lastIncome) / 1000; diff /= (60 * 60); @@ -96,7 +96,7 @@ module.exports = { date.setHours(date.getHours() + GuildDB.incomeLimiter); diff = (date - now) / 1000; let timeTillIncome = client.secondsToDhms(diff); - + const error = new EmbedBuilder() .setColor(client.config.Colors.Red) .setDescription(`You've already collected your income this week. Wait **${timeTillIncome}** to collect again.`); @@ -105,4 +105,4 @@ module.exports = { } }, }, -} \ No newline at end of file +} diff --git a/commands/compare-rating.js b/commands/compare-rating.js index 6096f47..162e39a 100644 --- a/commands/compare-rating.js +++ b/commands/compare-rating.js @@ -53,7 +53,7 @@ module.exports = { let comp; if (discord) comp = leaderboard.find(s => s.discordID == discord); - if (gamertag) comp = leaderboard.find(s => s.gamertag == gamertag); + if (gamertag) comp = leaderboard.find(s => s.gamertag == gamertag); let self = leaderboard.find(s => s.discordID == interaction.member.user.id); if (!client.exists(comp)) return interaction.send({ embeds: [new EmbedBuilder().setColor(client.config.Colors.Yellow).setDescription(`**Not Found** Unable to find any records with the gamertag or user provided.`)] }); @@ -90,7 +90,7 @@ module.exports = { const diff = Math.abs(selfData.length - compData.length); if (selfData.length < compData.length) selfData.unshift(...(new Array(diff).fill(null, 0, diff))); if (compData.length < selfData.length) compData.unshift(...(new Array(diff).fill(null, 0, diff))); - + const chart = { type: 'line', data: { @@ -131,7 +131,7 @@ module.exports = { }, }, }; - + const encodedChart = encodeURIComponent(JSON.stringify(chart)); const chartURL = `https://quickchart.io/chart?c=${encodedChart}&bkg=${encodeURIComponent("#ded8d7")}`; @@ -140,4 +140,4 @@ module.exports = { return interaction.send({ embeds: [statsEmbed] }); }, }, -} \ No newline at end of file +} diff --git a/commands/config.js b/commands/config.js index 9296510..be472ee 100644 --- a/commands/config.js +++ b/commands/config.js @@ -1,1143 +1,1143 @@ -const { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js'); -const CommandOptions = require('../util/CommandOptionTypes').CommandOptionTypes; -const bitfieldCalculator = require('discord-bitfield-calculator'); -const { getDefaultSettings } = require('../database/guild'); - -module.exports = { - name: "config", - debug: false, - global: false, - description: "Configure your server settings", - usage: "[options] [configuration]", - permissions: { - channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"], - member: ["MANAGE_GUILD"], - }, - options: [ - { - name: "killfeed", - description: "Configure the killfeed", - value: "killfeed", - type: CommandOptions.SubCommandGroup, - options: [ - { - name: "channel", - description: "Configure the killfeed channel", - value: "channel", - type: CommandOptions.SubCommand, - options: [{ - name: "channel", - description: "The channel to configure", - value: "channel", - type: CommandOptions.Channel, - required: true - }] - }, - { - name: "show_coords", - description: "Show the coordinates of the victim in the killfeed channel.", - value: "show_coords", - type: CommandOptions.SubCommand, - options: [{ - name: "configuration", - description: "True or False", - value: false, - type: CommandOptions.Boolean, - required: true, - }] - }, - { - name: "show_weapon", - description: "Show the image of the weapon in the killfeed", - value: "show_weapon", - type: CommandOptions.SubCommand, - options: [{ - name: "configuration", - description: "True or False", - value: false, - type: CommandOptions.Boolean, - required: true, - }] - } - ] - }, - { - name: "allowed_channels", - description: "Set channels you're allowed to use the bot in", - value: "allowed_channels", - type: CommandOptions.SubCommandGroup, - options: [ - { - name: "add", - description: "Add channel", - value: "add", - type: CommandOptions.SubCommand, - options: [{ - name: "channel", - description: "The channel to configure", - value: "channel", - type: CommandOptions.Channel, - channel_types: [0], // Restrict to text channel - required: true, - }] - }, - { - name: "remove", - description: "Remove channel", - value: "remove", - type: CommandOptions.SubCommand, - options: [{ - name: "channel", - description: "The channel to configure", - value: "channel", - type: CommandOptions.Channel, - channel_types: [0], // Restrict to text channel - required: true, - }] - }, - { - name: "clear", - description: "Clears all configured channels", - value: "clear", - type: CommandOptions.SubCommand, - }, - { - name: "view", - description: "View configured allowed channels", - value: "view", - type: CommandOptions.SubCommand, - } - ] - }, - { - name: "set_channel", - description: "Configure a channel", - value: "set_channel", - type: CommandOptions.SubCommand, - options:[ - { - name: "channel_type", - description: "Select the channel type", - value: "channel_type", - type: CommandOptions.String, - choices: [ - { name: 'Killfeed', value: 'killfeedChannel' }, { name: 'Admin Logs', value: 'connectionLogsChannel' }, - { name: 'Welcome', value: 'welcomeChannel' }, { name: 'Online Players', value: 'activePlayersChannel' }, - ], - required: true, - }, - { - name: "channel", - description: "The channel to configure", - value: "channel", - type: CommandOptions.Channel, - channel_types: [0], // Restrict to text channel - required: true, - }, - ] - }, - { - name: "linked_gt_role", - description: "Role for users with linked gamertags", - value: "linked_gt_role", - type: CommandOptions.SubCommand, - options: [{ - name: "role", - description: "Role to configure", - value: "role", - type: CommandOptions.Role, - required: true, - }] - }, - { - name: "member_role", - description: "Role for users who join the server", - value: "member_role", - type: CommandOptions.SubCommand, - options: [{ - name: "role", - description: "Role to configure", - value: "role", - type: CommandOptions.Role, - required: true, - }] - }, - { - name: "bot_admin_role", - description: "Set/remove bot admin role", - value: "bot_admin_role", - type: CommandOptions.SubCommandGroup, - options: [ - { - name: "add", - description: "Configure role to be bot admin", - value: "add", - type: CommandOptions.SubCommand, - options: [{ - name: "role", - description: "Role to confiure", - value: "role", - type: CommandOptions.Role, - required: true, - }] - }, - { - name: "remove", - description: "Remove configured role as bot admin", - value: "remove", - type: CommandOptions.SubCommand, - options: [{ - name: "role", - description: "Role to remove", - value: "role", - type: CommandOptions.Role, - required: true, - }] - }, - { - name: "view", - description: "View the configured bot admin roles", - value: "view", - type: CommandOptions.SubCommand, - } - ] - }, - { - name: "admin_ping_role", - description: "Admin role to ping in admin logs channel", - value: "admin_ping_role", - type: CommandOptions.SubCommand, - options: [{ - name: "role", - description: "Role to configure", - value: "role", - type: CommandOptions.Role, - required: true, - }] - }, - { - name: "exclude", - description: "Exclude roles that can be used to claim armbands", - value: "exclude", - type: CommandOptions.SubCommandGroup, - options: [ - { - name: "add", - description: "Configure role to be excluded", - value: "add", - type: CommandOptions.SubCommand, - options: [{ - name: "role", - description: "Role to confiure", - value: "role", - type: CommandOptions.Role, - required: true, - }] - }, - { - name: "remove", - description: "Remove configured role thats excluded", - value: "remove", - type: CommandOptions.SubCommand, - options: [{ - name: "role", - description: "Role to remove", - value: "role", - type: CommandOptions.Role, - required: true, - }] - }, - { - name: "view", - description: "View the configured excluded roles", - value: "view", - type: CommandOptions.SubCommand, - }, - ] - }, - { - name: "reset", - description: "Restore all settings to default configurations", - value: "reset", - type: CommandOptions.SubCommand, - }, - { - name: "view", - description: "View current settings configuration", - value: "view", - type: CommandOptions.SubCommand, - }, - { - name: "starting_balance", - description: "Set the starting balance of a new user", - value: "starting_balance", - type: CommandOptions.SubCommand, - options: [{ - name: "amount", - description: "The amount to set the starting balance", - value: "amount", - type: CommandOptions.Float, - min_value: 1.00, - required: true, - }] - }, - { - name: "uav-price", - description: "Configure the price of a UAV", - value: "uav-price", - type: CommandOptions.SubCommand, - options: [{ - name: "amount", - description: "The amount to set the UAV price", - value: "amount", - type: CommandOptions.Float, - min_value: 0.01, - required: true, - }] - }, - { - name: "emp-price", - description: "Configure the price of an EMP", - value: "emp-price", - type: CommandOptions.SubCommand, - options: [{ - name: "amount", - description: "The amount to set the EMP price", - value: "amount", - type: CommandOptions.Float, - min_value: 0.01, - required: true, - }] - }, - { - name: "income_role", - description: "Set/remove roles to recieve income", - value: "set_income_role", - type: CommandOptions.SubCommandGroup, - options: [ - { - name: "set", - description: "Set role", - value: "set", - type: CommandOptions.SubCommand, - options: [ - { - name: "role", - description: "Role to set", - value: "role", - type: CommandOptions.Role, - required: true, - }, - { - name: "amount", - description: "The amount to collect", - value: 120.00, - type: CommandOptions.Float, - min_value: 0.01, - required: true, - } - ] - }, - { - name: "remove", - description: "Remove role", - value: "remove", - type: CommandOptions.SubCommand, - options: [{ - name: "role", - description: "Role to remove", - value: "role", - type: CommandOptions.Role, - required: true, - }] - }, - ], - }, - { - name: "income_limiter", - description: "Change the number of hours to wait before collecting next income", - value: "income_limiter", - type: CommandOptions.SubCommand, - options: [{ - name: "hours", - description: "Number of hours till income can be collected", - value: 168.00, // 1 week - type: CommandOptions.Float, - min_value: 1.00, - required: true, - }] - }, - { - name: "combat-log-timer", - description: "Adjust number of minutes to detect combat logs (0 disables combat log)", - value: "combat-log-timer", - type: CommandOptions.SubCommand, - options: [{ - name: "minutes", - description: "Minutes to qualify combat log", - value: 5, - type: CommandOptions.Integer, - min_value: 0, - }] - }, - { - name: "toggle-uav-purchase", - description: "Allow/Disallow UAV purchases", - value: "toggle-uav-purchase", - type: CommandOptions.SubCommand, - options: [{ - name: "configuration", - description: "True or False", - value: false, - type: CommandOptions.Boolean, - required: true, - }] - }, - { - name: "toggle-emp-purchase", - description: "Allow/Disallow EMP purchases", - value: "toggle-uav-purchase", - type: CommandOptions.SubCommand, - options: [{ - name: "configuration", - description: "True or False", - value: false, - type: CommandOptions.Boolean, - required: true, - }] - }, - { - name: "welcome_message_server_name", - description: "Configure the server name in the welcome message", - value: "welcome_message_server_name", - type: CommandOptions.SubCommand, - options: [{ - name: "name", - description: "Server name to include in welcome message", - value: "name", - type: CommandOptions.String, - required: true, - }] - } - ], - SlashCommand: { - /** - * - * @param {require("../structures/DayzRBot")} client - * @param {import("discord.js").Message} message - * @param {string[]} args - * @param {*} param3 - */ - run: async (client, interaction, args, { GuildDB }) => { - const permissions = bitfieldCalculator.permissions(interaction.member.permissions); - let canUseCommand = false; - - if (permissions.includes("MANAGE_GUILD")) canUseCommand = true; - if (GuildDB.hasBotAdmin && interaction.member.roles.filter(e => GuildDB.botAdminRoles.indexOf(e) !== -1).length > 0) canUseCommand = true; - if (!canUseCommand) return interaction.send({ content: 'You don\'t have the permissions to use this command.' }); - - switch(args[0].name) { - - case 'allowed_channels': - const channels_config = args[0].options[0].name; - const channelid = ['add', 'remove'].includes(channels_config) ? args[0].options[0].options[0].value : null; - - if (channels_config == 'add') { - const channelAdd = client.GetChannel(channelid); - - const newChannelErrorEmbed = new EmbedBuilder().setColor(client.config.Colors.Red) - let error = false; - - if (!channelAdd) {error=true;newChannelErrorEmbed.setDescription(`**Error Notice:** Cannot find that channel.`);} - 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}}, (err, res) => { - if (err) return client.sendInternalError(interaction, err); - }); - - const successAddChannelEmbed = new EmbedBuilder() - .setColor(client.config.Colors.Green) - .setDescription(`**Success:** Set <#${channelid}> as an allowed channel.`); - - return interaction.send({ embeds: [successAddChannelEmbed] }); - } else if (channels_config == 'remove') { - - const errorChannelNotAvailable = new EmbedBuilder() - .setDescription(`**Error Notice:** <#${channelid}> is not in allowed channels.`) - .setColor(client.config.Colors.Red) - - if (!GuildDB.allowedChannels.includes(channelid)) return interaction.send({ embeds: [errorChannelNotAvailable] }); - - const promptRemoveChannel = new EmbedBuilder() - .setTitle(`Are you sure you want to remove this channel from allowed channels?`) - .setColor(client.config.Colors.Default) - - const optRemoveChannel = new ActionRowBuilder() - .addComponents( - new ButtonBuilder() - .setCustomId(`RemoveAllowedChannels-yes-${channelid}-${interaction.member.user.id}`) - .setLabel("Yes") - .setStyle(ButtonStyle.Danger), - new ButtonBuilder() - .setCustomId(`RemoveAllowedChannels-no-${channelid}-${interaction.member.user.id}`) - .setLabel("No") - .setStyle(ButtonStyle.Success) - ) - - return interaction.send({ embeds: [promptRemoveChannel], components: [optRemoveChannel], flags: (1 << 6) }); - - } else if (channels_config == 'clear') { - - const errorNoAllowedChannels = new EmbedBuilder() - .setDescription(`**Error Notice:**\n> No allowed channels configured to clear`) - .setColor(client.config.Colors.Red) - - if (GuildDB.allowedChannels.length == 0) return interaction.send({ embeds: [errorNoAllowedChannels] }); - - const promptClearChannels = new EmbedBuilder() - .setTitle(`Are you sure you want to clear all configured channels from allowed channels?`) - .setColor(client.config.Colors.Default) - - const optClearChannels = new ActionRowBuilder() - .addComponents( - new ButtonBuilder() - .setCustomId(`ClearAllowedChannels-yes-${interaction.member.user.id}`) - .setLabel("Yes") - .setStyle(ButtonStyle.Danger), - new ButtonBuilder() - .setCustomId(`ClearAllowedChannels-no-${interaction.member.user.id}`) - .setLabel("No") - .setStyle(ButtonStyle.Success) - ) - - return interaction.send({ embeds: [promptClearChannels], components: [optClearChannels], flags: (1 << 6) }); - - - } else if (channels_config == 'view') { - - if (!GuildDB.customChannelStatus) { - const noConfiguredChannels = new EmbedBuilder() - .setColor(client.config.Colors.Default) - .setTitle('Channels') - .setDescription('> There are no configured channels'); - - return interaction.send({ embeds: [noConfiguredChannels] }); - } - - const configuredChannels = new EmbedBuilder() - .setColor(client.config.Colors.Default) - .setTitle('Channels') - - let des = ''; - for (let i = 0; i < GuildDB.allowedChannels.length; i++) { - if (i == 0) des += `> <#${GuildDB.allowedChannels[i]}>`; - else des += `\n> <#${GuildDB.allowedChannels[i]}>`; - } - configuredChannels.setDescription(des); - - return interaction.send({ embeds: [configuredChannels] }); - - } - - case 'bot_admin_role': - const bot_admin_config = args[0].options[0].name; - const botAdminRoleId = ['add', 'remove'].includes(bot_admin_config) ? args[0].options[0].options[0].value : null; - if (bot_admin_config == 'add') { - - client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$push: {"server.botAdminRoles": botAdminRoleId}}, (err, res) => { - if (err) return client.sendInternalError(interaction, err); - }); - - const successSetBotAdminRoleEmbed = new EmbedBuilder() - .setDescription(`Successfully added <@&${botAdminRoleId}> as a bot admin role.\nUsers with this role can use restricted commands.`) - .setColor(client.config.Colors.Green); - - return interaction.send({ embeds: [successSetBotAdminRoleEmbed] }); - - } else if (bot_admin_config == 'remove') { - - if (!GuildDB.botAdminRoles.includes(botAdminRoleId)) { - const nonAdminRoleEmbed = new EmbedBuilder() - .setColor(client.config.Colors.Yellow) - .setDescription(`**Notice:**\n> The role <@&${botAdminRoleId}> has not been configured as a bot admin.`); - - return interaction.send({ embeds: [nonAdminRoleEmbed] }); - } - - const promptRemoveAdminRole = new EmbedBuilder() - .setTitle(`Are you sure you want to remove this role as a bot admin?`) - .setColor(client.config.Colors.Default) - - const optRemoveAdminRole = new ActionRowBuilder() - .addComponents( - new ButtonBuilder() - .setCustomId(`RemoveBotAdminRole-yes-${botAdminRoleId}-${interaction.member.user.id}`) - .setLabel("Yes") - .setStyle(ButtonStyle.Danger), - new ButtonBuilder() - .setCustomId(`RemoveBotAdminRole-no-${botAdminRoleId}-${interaction.member.user.id}`) - .setLabel("No") - .setStyle(ButtonStyle.Success) - ) - - return interaction.send({ embeds: [promptRemoveAdminRole], components: [optRemoveAdminRole], flags: (1 << 6) }); - - } else if (bot_admin_config == 'view') { - - if (GuildDB.botAdminRoles.length == 0) { - const noBotAdminRoles = new EmbedBuilder() - .setColor(client.config.Colors.Default) - .setTitle('Admin Roles') - .setDescription('> There have been no configured admin roles'); - - return interaction.send({ embeds: [noBotAdminRoles] }); - } - - const botAdminRolesEmbed = new EmbedBuilder() - .setColor(client.config.Colors.Default) - .setTitle('Admin Roles') - - let des = ''; - for (let i = 0; i < GuildDB.botAdminRoles.length; i++) { - des += `\n> <@&${GuildDB.botAdminRoles[i]}>`; - } - botAdminRolesEmbed.setDescription(des); - - return interaction.send({ embeds: [botAdminRolesEmbed] }); - - } - - case 'admin_ping_role': - 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); - }); - - const successSetAdminRoleEmbed = new EmbedBuilder() - .setDescription(`Successfully set <@&${args[0].options[0].value}> as the server admin role..`) - .setColor(client.config.Colors.Green); - - return interaction.send({ embeds: [successSetAdminRoleEmbed] }); - - case 'exclude': - const exclude_config = args[0].options[0].name; - const exclude_roleid = ['add', 'remove'].includes(exclude_config) ? args[0].options[0].options[0].value : null; - - if (exclude_config == 'add') { - client.dbo.collection('guilds').updateOne({'server.serverID': GuildDB.serverID}, {$push: {'server.excludedRoles': exclude_roleid}}, (err, res) => { - if (err) return client.sendInternalError(interaction, err); - }) - - const successExcludeEmbed = new EmbedBuilder() - .setColor(client.config.Colors.Green) - .setDescription(`**Done!**\n> Successfully added <@&${exclude_roleid}> to list of excluded roles.`) - - return interaction.send({ embeds: [successExcludeEmbed] }); - - } else if (exclude_config == 'remove') { - client.dbo.collection('guilds').updateOne({'server.serverID': GuildDB.serverID}, {$pull: {'server.excludedRoles': exclude_roleid}}, (err, res) => { - if (err) return client.sendInternalError(interaction, err); - }) - - const successRemoveExcludeEmbed = new EmbedBuilder() - .setColor(client.config.Colors.Green) - .setDescription(`**Done!**\n> Successfully removed <@&${exclude_roleid}> to list of excluded roles.`) - - return interaction.send({ embeds: [successRemoveExcludeEmbed] }); - - } else if (exclude_config == "view") { - - if (GuildDB.excludedRoles.length == 0) { - const noExcludedRoles = new EmbedBuilder() - .setColor(client.config.Colors.Default) - .setTitle('Excluded Roles') - .setDescription('> There have been no excluded roles'); - - return interaction.send({ embeds: [noExcludedRoles] }); - } - - const excludedRolesEmbed = new EmbedBuilder() - .setColor(client.config.Colors.Default) - .setTitle('Excluded Roles') - - let des = ''; - for (let i = 0; i < GuildDB.excludedRoles.length; i++) { - des += `\n> <@&${GuildDB.excludedRoles[i]}>`; - } - excludedRolesEmbed.setDescription(des); - - return interaction.send({ embeds: [excludedRolesEmbed] }); - - } - - case 'reset': - const promptReset = new EmbedBuilder() - .setTitle(`Woah!? Hold on.`) - .setDescription('Are you sure you wish to remove all your configurations for this guild?') - .setColor(client.config.Colors.Default) - - const optReset = new ActionRowBuilder() - .addComponents( - new ButtonBuilder() - .setCustomId(`ResetSettings-yes-${interaction.member.user.id}`) - .setLabel("Yes") - .setStyle(ButtonStyle.Danger), - new ButtonBuilder() - .setCustomId(`ResetSettings-no-${interaction.member.user.id}`) - .setLabel("No") - .setStyle(ButtonStyle.Success) - ) - - return interaction.send({ embeds: [promptReset], components: [optReset], flags: (1 << 6) }); - - case 'view': - - // wrappers - const w = "\`\`\`"; - const a = "ansi\n"; - const f = "fix\n"; - const m = "arm\n" - const g = ""; - const r = ""; - - // boolean display - const autoRestart = GuildDB.autoRestart ? `${g}true` : `${r}false`; - const showKillfeedCoords = GuildDB.showKillfeedCoords ? `${g}true` : `${r}false`; - const showKillfeedWeapon = GuildDB.showKillfeedWeapon ? `${g}true` : `${r}false`; - const purchaseUAV = GuildDB.purchaseUAV ? `${g}true` : `${r}false`; - const purchaseEMP = GuildDB.purchaseEMP ? `${g}true` : `${r}false`; - const adminRoles = GuildDB.hasBotAdmin ? `${g}true` : `${r}false` - const excludedRoles = GuildDB.hasExcludedRoles ? `${g}true` : `${r}false`; - - // Role / channel display - const NONE = `${w}${m}none${w}`; - const channelsInfo = GuildDB.customChannelStatus ? '\`\` to view' : NONE; - const killfeedChannel = client.exists(GuildDB.killfeedChannel) ? `<#${GuildDB.killfeedChannel}>` : NONE; - const connectionLogs = client.exists(GuildDB.connectionLogsChannel) ? `<#${GuildDB.connectionLogsChannel}>` : NONE; - const activePlayers = client.exists(GuildDB.activePlayersChannel) ? `<#${GuildDB.activePlayersChannel}>` : NONE; - const welcomeChannel = client.exists(GuildDB.welcomeChannel) ? `<#${GuildDB.welcomeChannel}>` : NONE; - const linkedGTRole = client.exists(GuildDB.linkedGamertagRole) ? `<@&${GuildDB.linkedGamertagRole}>` : NONE; - const memberRole = client.exists(GuildDB.memberRole) ? `<@&${GuildDB.memberRole}>` : NONE; - - // value display - const incomeLimiter = `${GuildDB.incomeLimiter} hours`; - const startingBalance = `$${GuildDB.startingBalance.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2})}`; - const uavPrice = `$${GuildDB.uavPrice.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2})}`; - const empPrice = `$${GuildDB.empPrice.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2})}`; - const combatLogTimer = `${GuildDB.combatLogTimer} minutes`; - - // Ugly below but kinda nice above - const settingsEmbed = new EmbedBuilder() - .setColor(client.config.Colors.Default) - .setTitle('Current Guild Configurations') - .addFields( - { name: 'Guild ID', value: `${w}${f}${GuildDB.serverID}${w}`, inline: true }, - { name: 'Server Name', value: `${w}${f}${GuildDB.serverName}${w}`, inline: true }, - { name: 'Auto Restart', value: `${w}${a}${autoRestart}${w}`, inline: true }, - { name: 'UAVs Enabled', value: `${w}${a}${purchaseUAV}${w}`, inline: true }, - { name: 'EMPs Enabled', value: `${w}${a}${purchaseEMP}${w}`, inline: true }, - { name: 'Show Killfeed Coords', value: `${w}${a}${showKillfeedCoords}${w}`, inline: true }, - { name: 'Show Killfeed Weapons', value: `${w}${a}${showKillfeedWeapon}${w}`, inline: true }, - { name: 'Has Admin Rols', value: `${w}${a}${adminRoles}${w}`, inline: true }, - { name: 'Has Excluded Roles', value: `${w}${a}${excludedRoles}${w}`, inline: true }, - { name: 'Allowed Channels', value: `${channelsInfo}`, inline: true }, - { name: 'Killfeed Channel', value: `${killfeedChannel}`, inline: true }, - { name: 'Connection Logs Channel', value: `${connectionLogs}`, inline: true }, - { name: 'Player List Channel', value: `${activePlayers}`, inline: true }, - { name: 'Welcome Channel', value: `${welcomeChannel}`, inline: true }, - { name: 'Linked Gamertag Role', value: `${linkedGTRole}`, inline: true }, - { name: 'Member Role', value: `${memberRole}`, inline: true }, - { name: 'Income Limiter', value: `${w}${f}${incomeLimiter}${w}`, inline: true }, - { name: 'Starting Balance', value: `${w}${f}${startingBalance}${w}`, inline: true }, - { name: 'UAV Price', value: `${w}${f}${uavPrice}${w}`, inline: true }, - { name: 'EMP Price', value: `${w}${f}${empPrice}${w}`, inline: true }, - { name: 'Combat Log Timer', value: `${w}${f}${combatLogTimer}${w}`, inline: true }, - ); - - return interaction.send({ embeds: [settingsEmbed] }); - - case 'set_channel': - const channelType = args[0].options[0].value; - const channel = args[0].options[1].value; - - client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$set: {[`server.${channelType}`]: channel}}, (err, res) => { - if (err) return client.sendInternalError(interaction, err); - }); - - const successSetChannelEmbed = new EmbedBuilder() - .setDescription(`Successfully set <#${channel}> as the ${channelType} channel.`) - .setColor(client.config.Colors.Green); - - return interaction.send({ embeds: [successSetChannelEmbed] }); - - 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}}, (err, res) => { - if (err) return client.sendInternalError(interaction, err); - }); - - const successLinkedGTRoleEmbed = new EmbedBuilder() - .setDescription(`Successfully set <@&${linked_gt_role}> to give to users who link their gamertag.`) - .setColor(client.config.Colors.Green); - - return interaction.send({ embeds: [successLinkedGTRoleEmbed] }); - - 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}}, (err, res) => { - if (err) return client.sendInternalError(interaction, err); - }); - - const successMemberRoleEmbed = new EmbedBuilder() - .setDescription(`Successfully set <@&${member_role}> to give to users who link they join.`) - .setColor(client.config.Colors.Green); - - 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}}, (err, res) => { - if (err) return client.sendInternalError(interaction, err); - }); - - let successSetStartingBalanceEmbed = new EmbedBuilder() - .setColor(client.config.Colors.Green) - .setDescription(`Successfully set $${args[0].options[0].value.toFixed(2)} as starting balance`); - - return interaction.send({ embeds: [successSetStartingBalanceEmbed] }); - - case 'income_role': - if (args[0].options[0].name== 'set') { - const incomeRoleId = args[0].options[0].options[0].value - - if (args[0].options[0].options[1].value <= 0) { - let errorIncomeAmount = new EmbedBuilder() - .setDescription('**Error Notice:** Amount cannot be $0 or less than $0.') - .setColor(client.config.Colors.Red); - - return interaction.send({ embeds: [errorIncomeAmount] }); - } - - const searchIndex = GuildDB.incomeRoles.findIndex((role) => role.role==incomeRoleId); - if (searchIndex == -1) { - const newIncome = { - role: incomeRoleId, - income: args[0].options[0].options[1].value, - } - - client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$push: {"server.incomeRoles":newIncome}}, (err, res) => { - if (err) return client.sendInternalError(interaction, err); - }); - } else { - client.dbo.collection("guilds").updateOne({ - "server.serverID": GuildDB.serverID, - "server.incomeRoles.role": incomeRoleId - }, - { - $set: { - "server.incomeRoles.$.income": args[0].options[0].options[1].value - } - }, (err, res) => { - if (err) return client.sendInternalError(interaction, err); - }); - } - const perform = searchIndex == -1 ? 'set' : 'updated'; - - const successIncomeRoleEmbed = new EmbedBuilder() - .setDescription(`Successfully ${perform} <@&${incomeRoleId}>'s income to $${args[0].options[0].options[1].value}`) - .setColor(client.config.Colors.Green); - - return interaction.send({ embeds: [successIncomeRoleEmbed] }); - - } else if (args[0].options[0].name== 'remove') { - const searchIndex = GuildDB.incomeRoles.findIndex((role) => role.role==incomeRoleId); - if (searchIndex == -1) { - const errorIncomeNotFoundEmbed = new EmbedBuilder() - .setDescription('**Error Notice:** Role not found') - .setColor(client.config.Colors.Red); - - return interaction.send({ embeds: [errorIncomeNotFoundEmbed] }); - } else { - const promptRemoveIncomeRole = new EmbedBuilder() - .setTitle(`Are you sure you want to remove this role as an income?`) - .setColor(client.config.Colors.Default) - - const optRemoveIncomeRole = new ActionRowBuilder() - .addComponents( - new ButtonBuilder() - .setCustomId(`RemoveIncomeRole-yes-${incomeRoleId}-${interaction.member.user.id}`) - .setLabel("Yes") - .setStyle(ButtonStyle.Danger), - new ButtonBuilder() - .setCustomId(`RemoveIncomeRole-no-${incomeRoleId}-${interaction.member.user.id}`) - .setLabel("No") - .setStyle(ButtonStyle.Success) - ) - - return interaction.send({ embeds: [promptRemoveIncomeRole], components: [optRemoveIncomeRole], flags: (1 << 6) }); - } - } - - case 'income_limiter': - 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); - }); - - let successIncomeLimiterEmbed = new EmbedBuilder() - .setColor(client.config.Colors.Green) - .setDescription(`Successfully set **${args[0].options[0].value} hours** as the wait time to collect income.`); - - 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}}, (err, res) => { - if (err) return client.sendInternalError(interaction, err); - }); - - let successUAVPriceEmbed = new EmbedBuilder() - .setColor(client.config.Colors.Green) - .setDescription(`Successfully set $${args[0].options[0].value.toFixed(2)} as UAV price`); - - 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}}, (err, res) => { - if (err) return client.sendInternalError(interaction, err); - }); - - let successEMPPriceEmbed = new EmbedBuilder() - .setColor(client.config.Colors.Green) - .setDescription(`Successfully set $${args[0].options[0].value.toFixed(2)} as EMP price`); - - return interaction.send({ embeds: [successEMPPriceEmbed] }); - - case 'combat-log-timer': - client.dbo.collection("guilds").updateOne({"server.serverID": GuildDB.serverID}, {$set: {"server.combatLogTimer":args[0].options[0].value}}, (err, res) => { - if (err) return client.sendInternalError(interaction, err); - }); - - let successCobatLogTimerEmbed = new EmbedBuilder() - .setColor(client.config.Colors.Green) - .setDescription(`Successfully set combat log timer to **${args[0].options[0].value.toFixed(0)} minutes.**`); - - return interaction.send({ embeds: [successCobatLogTimerEmbed] }); - - case 'toggle-uav-purchase': - const togggleUAVpurchase = args[0].options[0].value ? 1 : 0; - - client.dbo.collection("guilds").updateOne({"server.serverID": GuildDB.serverID}, {$set: {"server.purchaseUAV": togggleUAVpurchase}}, (err, res) => { - if (err) return client.sendInternalError(interaction, err); - }); - - let successToggleUAVpurchaseEmbed = new EmbedBuilder() - .setColor(client.config.Colors.Green) - .setDescription(`Users can ${togggleUAVpurchase ? 'now' : 'no longer'} purchase UAVs.`); - - return interaction.send({ embeds: [successToggleUAVpurchaseEmbed] }); - - case 'toggle-emp-purchase': - const togggleEMPpurchase = args[0].options[0].value ? 1 : 0; - - client.dbo.collection("guilds").updateOne({"server.serverID": GuildDB.serverID}, {$set: {"server.purchaseEMP": togggleEMPpurchase}}, (err, res) => { - if (err) return client.sendInternalError(interaction, err); - }); - - let successToggleEMPpurchaseEmbed = new EmbedBuilder() - .setColor(client.config.Colors.Green) - .setDescription(`Users can ${togggleUAVpurchase ? 'now' : 'no longer'} purchase EMPs.`); - - return interaction.send({ embeds: [successToggleEMPpurchaseEmbed] }); - - case 'killfeed': - const killfeed_configuration = args[0].options[0].name; - - if (killfeed_configuration == 'channel') { - - const channel = args[0].options[0].options[0].value; - - client.dbo.collection("guilds").updateOne({"server.serverID": GuildDB.serverID},{$set: {'server.killfeedChannel': channel}}, (err, res) => { - if (err) return client.sendInternalError(interaction, err); - }); - - const successConfigureKillfeedChannel = new EmbedBuilder() - .setColor(client.config.Colors.Green) - .setDescription(`Successfully configured the killfeed channel to <#${channel}>`); - - return interaction.send({ embeds: [successConfigureKillfeedChannel] }); - - } else if (killfeed_configuration == 'show_coords') { - const showKillfeedCoordsConfiguration = args[0].options[0].options[0].value ? 1 : 0; - - client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$set: {"server.showKillfeedCoords": showKillfeedCoordsConfiguration}}, (err, res) => { - if (err) return client.sendInternalError(interaction, err); - }); - - const successConfigureShowKillfeedCoords = new EmbedBuilder() - .setDescription(`Successfully configured the killfeed to ${showKillfeedCoordsConfiguration ? 'show' : 'not show'} coordinates.`) - .setColor(client.config.Colors.Green); - - return interaction.send({ embeds: [successConfigureShowKillfeedCoords] }); - - } else if (killfeed_configuration == 'show_weapon') { - - const showKillfeedWeaponConfiguration = args[0].options[0].options[0].value ? 1 : 0; - - client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$set: {"server.showKillfeedWeapon": showKillfeedWeaponConfiguration}}, (err, res) => { - if (err) return client.sendInternalError(interaction, err); - }); - - const successConfigureShowKillfeedCoords = new EmbedBuilder() - .setDescription(`Successfully configured the killfeed to ${showKillfeedWeaponConfiguration ? 'show' : 'not show'} weapon icons.`) - .setColor(client.config.Colors.Green); - - return interaction.send({ embeds: [successConfigureShowKillfeedCoords] }); - - } - - case 'welcome_message_server_name': - const server_name = args[0].options[0].value; - - client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$set: {"server.serverName":server_name}}, (err, res) => { - if (err) return client.sendInternalError(interacion, err); - }); - - const succcessUpdateServerName = new EmbedBuilder() - .setDescription(`Successfully configured the server name to **${server_name}** in the welcome message.`) - .setColor(client.config.Colors.Green); - - return interaction.send({ embeds: [succcessUpdateServerName] }); - - default: - return client.sendInternalError(interaction, 'There was an error parsing the config command'); - } - }, - }, - - Interactions: { - - RemoveAllowedChannels: { - run: async (client, interaction, GuildDB) => { - if (!interaction.customId.endsWith(interaction.member.user.id)) { - return interaction.reply({ - content: "This button is not for you", - flags: (1 << 6) - }) - } - let action = '' - if (interaction.customId.split('-')[1]=='yes') { - action = 'removed'; - client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$pull:{"server.allowedChannels": interaction.customId.split('-')[2]}}, (err, res) => { - if (err) return client.sendInternalError(interaction, err); - }); - } else if (interaction.customId.split('-')[1]=='no') action = 'kept'; - - const successEmbed = new EmbedBuilder() - .setColor(client.config.Colors.Green) - .setTitle(`**Success**\n> Successfullly ${action} the channel.`) - - return interaction.update({ embeds: [successEmbed], components: [] }); - } - }, - - ClearAllowedChannels: { - run: async (client, interaction, GuildDB) => { - if (!interaction.customId.endsWith(interaction.member.user.id)) { - return interaction.reply({ - content: "This buttpm is not for you", - flags: (1 << 6) - }); - } - let action; - if (interaction.customId.split('-')[1] == 'yes') { - action = 'cleared'; - client.dbo.collection("guilds").updateOne({"server.serverID": GuildDB.serverID}, {$set:{"server.allowedChannels":[]}}, (err, res) => { - if (err) return client.sendInternalError(interaction, err); - }) - } else if (interaction.customId.split('-')[1] == 'no') action = 'kept'; - - const successEmbed = new EmbedBuilder() - .setColor(client.config.Colors.Green) - .setTitle(`**Success**\n> Successfully ${action} all configured channels.`); - - return interaction.update({ embeds: [successEmbed], components: [] }); - } - }, - - RemoveBotAdminRole: { - run: async (client, interaction, GuildDB) => { - if (!interaction.customId.endsWith(interaction.member.user.id)) { - return ButtonInteraction.reply({ - content: "This button is not for you", - flags: (1 << 6) - }) - } - let action = ''; - 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}}, (err, res) => { - if (err) return client.sendInternalError(interaction, err); - }); - } else if (interaction.customId.split('-')[1]=='no') action = 'kept'; - - const successEmbed = new EmbedBuilder() - .setColor(client.config.Colors.Green) - .setDescription(`**Successfully ${action} <@&${roleId}> as the bot admin role.**`) - - return interaction.update({ embeds: [successEmbed], components: [] }); - } - }, - - RemoveIncomeRole: { - run: async (client, interaction, GuildDB) => { - if (!interaction.customId.endsWith(interaction.member.user.id)) { - return ButtonInteraction.reply({ - content: "This button is not for you", - flags: (1 << 6) - }) - } - let action = ''; - let roleId = interaction.customId.split('-')[2]; - 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}}, (err, res) => { - if (err) return client.sendInternalError(interaction, err); - }); - } else if (interaction.customId.split('-')[1]=='no') action = 'kept'; - - const successEmbed = new EmbedBuilder() - .setColor(client.config.Colors.Green) - .setDescription(`**Successfully ${action} <@&${roleId}> as an income role.**`) - - return interaction.update({ embeds: [successEmbed], components: [] }); - } - }, - - ResetSettings: { - run: async (client, interaction, GuildDB) => { - if (!interaction.customId.endsWith(interaction.member.user.id)) { - return ButtonInteraction.reply({ - content: "This button is not for you", - flags: (1 << 6) - }) - } - let action = ''; - if (interaction.customId.split('-')[1]=='yes') { - action = 'reset'; - const defaultGuildConfig = getDefaultSettings(GuildDB.serverID); - 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'; - - const successEmbed = new EmbedBuilder() - .setColor(client.config.Colors.Green) - .setTitle(`Successfully ${action} guild configurations.`) - - return interaction.update({ embeds: [successEmbed], components: [] }); - } - } - } -} \ No newline at end of file +const { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js'); +const CommandOptions = require('../util/CommandOptionTypes').CommandOptionTypes; +const bitfieldCalculator = require('discord-bitfield-calculator'); +const { getDefaultSettings } = require('../database/guild'); + +module.exports = { + name: "config", + debug: false, + global: false, + description: "Configure your server settings", + usage: "[options] [configuration]", + permissions: { + channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"], + member: ["MANAGE_GUILD"], + }, + options: [ + { + name: "killfeed", + description: "Configure the killfeed", + value: "killfeed", + type: CommandOptions.SubCommandGroup, + options: [ + { + name: "channel", + description: "Configure the killfeed channel", + value: "channel", + type: CommandOptions.SubCommand, + options: [{ + name: "channel", + description: "The channel to configure", + value: "channel", + type: CommandOptions.Channel, + required: true + }] + }, + { + name: "show_coords", + description: "Show the coordinates of the victim in the killfeed channel.", + value: "show_coords", + type: CommandOptions.SubCommand, + options: [{ + name: "configuration", + description: "True or False", + value: false, + type: CommandOptions.Boolean, + required: true, + }] + }, + { + name: "show_weapon", + description: "Show the image of the weapon in the killfeed", + value: "show_weapon", + type: CommandOptions.SubCommand, + options: [{ + name: "configuration", + description: "True or False", + value: false, + type: CommandOptions.Boolean, + required: true, + }] + } + ] + }, + { + name: "allowed_channels", + description: "Set channels you're allowed to use the bot in", + value: "allowed_channels", + type: CommandOptions.SubCommandGroup, + options: [ + { + name: "add", + description: "Add channel", + value: "add", + type: CommandOptions.SubCommand, + options: [{ + name: "channel", + description: "The channel to configure", + value: "channel", + type: CommandOptions.Channel, + channel_types: [0], // Restrict to text channel + required: true, + }] + }, + { + name: "remove", + description: "Remove channel", + value: "remove", + type: CommandOptions.SubCommand, + options: [{ + name: "channel", + description: "The channel to configure", + value: "channel", + type: CommandOptions.Channel, + channel_types: [0], // Restrict to text channel + required: true, + }] + }, + { + name: "clear", + description: "Clears all configured channels", + value: "clear", + type: CommandOptions.SubCommand, + }, + { + name: "view", + description: "View configured allowed channels", + value: "view", + type: CommandOptions.SubCommand, + } + ] + }, + { + name: "set_channel", + description: "Configure a channel", + value: "set_channel", + type: CommandOptions.SubCommand, + options:[ + { + name: "channel_type", + description: "Select the channel type", + value: "channel_type", + type: CommandOptions.String, + choices: [ + { name: 'Killfeed', value: 'killfeedChannel' }, { name: 'Admin Logs', value: 'connectionLogsChannel' }, + { name: 'Welcome', value: 'welcomeChannel' }, { name: 'Online Players', value: 'activePlayersChannel' }, + ], + required: true, + }, + { + name: "channel", + description: "The channel to configure", + value: "channel", + type: CommandOptions.Channel, + channel_types: [0], // Restrict to text channel + required: true, + }, + ] + }, + { + name: "linked_gt_role", + description: "Role for users with linked gamertags", + value: "linked_gt_role", + type: CommandOptions.SubCommand, + options: [{ + name: "role", + description: "Role to configure", + value: "role", + type: CommandOptions.Role, + required: true, + }] + }, + { + name: "member_role", + description: "Role for users who join the server", + value: "member_role", + type: CommandOptions.SubCommand, + options: [{ + name: "role", + description: "Role to configure", + value: "role", + type: CommandOptions.Role, + required: true, + }] + }, + { + name: "bot_admin_role", + description: "Set/remove bot admin role", + value: "bot_admin_role", + type: CommandOptions.SubCommandGroup, + options: [ + { + name: "add", + description: "Configure role to be bot admin", + value: "add", + type: CommandOptions.SubCommand, + options: [{ + name: "role", + description: "Role to confiure", + value: "role", + type: CommandOptions.Role, + required: true, + }] + }, + { + name: "remove", + description: "Remove configured role as bot admin", + value: "remove", + type: CommandOptions.SubCommand, + options: [{ + name: "role", + description: "Role to remove", + value: "role", + type: CommandOptions.Role, + required: true, + }] + }, + { + name: "view", + description: "View the configured bot admin roles", + value: "view", + type: CommandOptions.SubCommand, + } + ] + }, + { + name: "admin_ping_role", + description: "Admin role to ping in admin logs channel", + value: "admin_ping_role", + type: CommandOptions.SubCommand, + options: [{ + name: "role", + description: "Role to configure", + value: "role", + type: CommandOptions.Role, + required: true, + }] + }, + { + name: "exclude", + description: "Exclude roles that can be used to claim armbands", + value: "exclude", + type: CommandOptions.SubCommandGroup, + options: [ + { + name: "add", + description: "Configure role to be excluded", + value: "add", + type: CommandOptions.SubCommand, + options: [{ + name: "role", + description: "Role to confiure", + value: "role", + type: CommandOptions.Role, + required: true, + }] + }, + { + name: "remove", + description: "Remove configured role thats excluded", + value: "remove", + type: CommandOptions.SubCommand, + options: [{ + name: "role", + description: "Role to remove", + value: "role", + type: CommandOptions.Role, + required: true, + }] + }, + { + name: "view", + description: "View the configured excluded roles", + value: "view", + type: CommandOptions.SubCommand, + }, + ] + }, + { + name: "reset", + description: "Restore all settings to default configurations", + value: "reset", + type: CommandOptions.SubCommand, + }, + { + name: "view", + description: "View current settings configuration", + value: "view", + type: CommandOptions.SubCommand, + }, + { + name: "starting_balance", + description: "Set the starting balance of a new user", + value: "starting_balance", + type: CommandOptions.SubCommand, + options: [{ + name: "amount", + description: "The amount to set the starting balance", + value: "amount", + type: CommandOptions.Float, + min_value: 1.00, + required: true, + }] + }, + { + name: "uav-price", + description: "Configure the price of a UAV", + value: "uav-price", + type: CommandOptions.SubCommand, + options: [{ + name: "amount", + description: "The amount to set the UAV price", + value: "amount", + type: CommandOptions.Float, + min_value: 0.01, + required: true, + }] + }, + { + name: "emp-price", + description: "Configure the price of an EMP", + value: "emp-price", + type: CommandOptions.SubCommand, + options: [{ + name: "amount", + description: "The amount to set the EMP price", + value: "amount", + type: CommandOptions.Float, + min_value: 0.01, + required: true, + }] + }, + { + name: "income_role", + description: "Set/remove roles to recieve income", + value: "set_income_role", + type: CommandOptions.SubCommandGroup, + options: [ + { + name: "set", + description: "Set role", + value: "set", + type: CommandOptions.SubCommand, + options: [ + { + name: "role", + description: "Role to set", + value: "role", + type: CommandOptions.Role, + required: true, + }, + { + name: "amount", + description: "The amount to collect", + value: 120.00, + type: CommandOptions.Float, + min_value: 0.01, + required: true, + } + ] + }, + { + name: "remove", + description: "Remove role", + value: "remove", + type: CommandOptions.SubCommand, + options: [{ + name: "role", + description: "Role to remove", + value: "role", + type: CommandOptions.Role, + required: true, + }] + }, + ], + }, + { + name: "income_limiter", + description: "Change the number of hours to wait before collecting next income", + value: "income_limiter", + type: CommandOptions.SubCommand, + options: [{ + name: "hours", + description: "Number of hours till income can be collected", + value: 168.00, // 1 week + type: CommandOptions.Float, + min_value: 1.00, + required: true, + }] + }, + { + name: "combat-log-timer", + description: "Adjust number of minutes to detect combat logs (0 disables combat log)", + value: "combat-log-timer", + type: CommandOptions.SubCommand, + options: [{ + name: "minutes", + description: "Minutes to qualify combat log", + value: 5, + type: CommandOptions.Integer, + min_value: 0, + }] + }, + { + name: "toggle-uav-purchase", + description: "Allow/Disallow UAV purchases", + value: "toggle-uav-purchase", + type: CommandOptions.SubCommand, + options: [{ + name: "configuration", + description: "True or False", + value: false, + type: CommandOptions.Boolean, + required: true, + }] + }, + { + name: "toggle-emp-purchase", + description: "Allow/Disallow EMP purchases", + value: "toggle-uav-purchase", + type: CommandOptions.SubCommand, + options: [{ + name: "configuration", + description: "True or False", + value: false, + type: CommandOptions.Boolean, + required: true, + }] + }, + { + name: "welcome_message_server_name", + description: "Configure the server name in the welcome message", + value: "welcome_message_server_name", + type: CommandOptions.SubCommand, + options: [{ + name: "name", + description: "Server name to include in welcome message", + value: "name", + type: CommandOptions.String, + required: true, + }] + } + ], + SlashCommand: { + /** + * + * @param {require("../structures/DayzRBot")} client + * @param {import("discord.js").Message} message + * @param {string[]} args + * @param {*} param3 + */ + run: async (client, interaction, args, { GuildDB }) => { + const permissions = bitfieldCalculator.permissions(interaction.member.permissions); + let canUseCommand = false; + + if (permissions.includes("MANAGE_GUILD")) canUseCommand = true; + if (GuildDB.hasBotAdmin && interaction.member.roles.filter(e => GuildDB.botAdminRoles.indexOf(e) !== -1).length > 0) canUseCommand = true; + if (!canUseCommand) return interaction.send({ content: 'You don\'t have the permissions to use this command.' }); + + switch(args[0].name) { + + case 'allowed_channels': + const channels_config = args[0].options[0].name; + const channelid = ['add', 'remove'].includes(channels_config) ? args[0].options[0].options[0].value : null; + + if (channels_config == 'add') { + const channelAdd = client.GetChannel(channelid); + + const newChannelErrorEmbed = new EmbedBuilder().setColor(client.config.Colors.Red) + let error = false; + + if (!channelAdd) {error=true;newChannelErrorEmbed.setDescription(`**Error Notice:** Cannot find that channel.`);} + 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}}, (err, res) => { + if (err) return client.sendInternalError(interaction, err); + }); + + const successAddChannelEmbed = new EmbedBuilder() + .setColor(client.config.Colors.Green) + .setDescription(`**Success:** Set <#${channelid}> as an allowed channel.`); + + return interaction.send({ embeds: [successAddChannelEmbed] }); + } else if (channels_config == 'remove') { + + const errorChannelNotAvailable = new EmbedBuilder() + .setDescription(`**Error Notice:** <#${channelid}> is not in allowed channels.`) + .setColor(client.config.Colors.Red) + + if (!GuildDB.allowedChannels.includes(channelid)) return interaction.send({ embeds: [errorChannelNotAvailable] }); + + const promptRemoveChannel = new EmbedBuilder() + .setTitle(`Are you sure you want to remove this channel from allowed channels?`) + .setColor(client.config.Colors.Default) + + const optRemoveChannel = new ActionRowBuilder() + .addComponents( + new ButtonBuilder() + .setCustomId(`RemoveAllowedChannels-yes-${channelid}-${interaction.member.user.id}`) + .setLabel("Yes") + .setStyle(ButtonStyle.Danger), + new ButtonBuilder() + .setCustomId(`RemoveAllowedChannels-no-${channelid}-${interaction.member.user.id}`) + .setLabel("No") + .setStyle(ButtonStyle.Success) + ) + + return interaction.send({ embeds: [promptRemoveChannel], components: [optRemoveChannel], flags: (1 << 6) }); + + } else if (channels_config == 'clear') { + + const errorNoAllowedChannels = new EmbedBuilder() + .setDescription(`**Error Notice:**\n> No allowed channels configured to clear`) + .setColor(client.config.Colors.Red) + + if (GuildDB.allowedChannels.length == 0) return interaction.send({ embeds: [errorNoAllowedChannels] }); + + const promptClearChannels = new EmbedBuilder() + .setTitle(`Are you sure you want to clear all configured channels from allowed channels?`) + .setColor(client.config.Colors.Default) + + const optClearChannels = new ActionRowBuilder() + .addComponents( + new ButtonBuilder() + .setCustomId(`ClearAllowedChannels-yes-${interaction.member.user.id}`) + .setLabel("Yes") + .setStyle(ButtonStyle.Danger), + new ButtonBuilder() + .setCustomId(`ClearAllowedChannels-no-${interaction.member.user.id}`) + .setLabel("No") + .setStyle(ButtonStyle.Success) + ) + + return interaction.send({ embeds: [promptClearChannels], components: [optClearChannels], flags: (1 << 6) }); + + + } else if (channels_config == 'view') { + + if (!GuildDB.customChannelStatus) { + const noConfiguredChannels = new EmbedBuilder() + .setColor(client.config.Colors.Default) + .setTitle('Channels') + .setDescription('> There are no configured channels'); + + return interaction.send({ embeds: [noConfiguredChannels] }); + } + + const configuredChannels = new EmbedBuilder() + .setColor(client.config.Colors.Default) + .setTitle('Channels') + + let des = ''; + for (let i = 0; i < GuildDB.allowedChannels.length; i++) { + if (i == 0) des += `> <#${GuildDB.allowedChannels[i]}>`; + else des += `\n> <#${GuildDB.allowedChannels[i]}>`; + } + configuredChannels.setDescription(des); + + return interaction.send({ embeds: [configuredChannels] }); + + } + + case 'bot_admin_role': + const bot_admin_config = args[0].options[0].name; + const botAdminRoleId = ['add', 'remove'].includes(bot_admin_config) ? args[0].options[0].options[0].value : null; + if (bot_admin_config == 'add') { + + client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$push: {"server.botAdminRoles": botAdminRoleId}}, (err, res) => { + if (err) return client.sendInternalError(interaction, err); + }); + + const successSetBotAdminRoleEmbed = new EmbedBuilder() + .setDescription(`Successfully added <@&${botAdminRoleId}> as a bot admin role.\nUsers with this role can use restricted commands.`) + .setColor(client.config.Colors.Green); + + return interaction.send({ embeds: [successSetBotAdminRoleEmbed] }); + + } else if (bot_admin_config == 'remove') { + + if (!GuildDB.botAdminRoles.includes(botAdminRoleId)) { + const nonAdminRoleEmbed = new EmbedBuilder() + .setColor(client.config.Colors.Yellow) + .setDescription(`**Notice:**\n> The role <@&${botAdminRoleId}> has not been configured as a bot admin.`); + + return interaction.send({ embeds: [nonAdminRoleEmbed] }); + } + + const promptRemoveAdminRole = new EmbedBuilder() + .setTitle(`Are you sure you want to remove this role as a bot admin?`) + .setColor(client.config.Colors.Default) + + const optRemoveAdminRole = new ActionRowBuilder() + .addComponents( + new ButtonBuilder() + .setCustomId(`RemoveBotAdminRole-yes-${botAdminRoleId}-${interaction.member.user.id}`) + .setLabel("Yes") + .setStyle(ButtonStyle.Danger), + new ButtonBuilder() + .setCustomId(`RemoveBotAdminRole-no-${botAdminRoleId}-${interaction.member.user.id}`) + .setLabel("No") + .setStyle(ButtonStyle.Success) + ) + + return interaction.send({ embeds: [promptRemoveAdminRole], components: [optRemoveAdminRole], flags: (1 << 6) }); + + } else if (bot_admin_config == 'view') { + + if (GuildDB.botAdminRoles.length == 0) { + const noBotAdminRoles = new EmbedBuilder() + .setColor(client.config.Colors.Default) + .setTitle('Admin Roles') + .setDescription('> There have been no configured admin roles'); + + return interaction.send({ embeds: [noBotAdminRoles] }); + } + + const botAdminRolesEmbed = new EmbedBuilder() + .setColor(client.config.Colors.Default) + .setTitle('Admin Roles') + + let des = ''; + for (let i = 0; i < GuildDB.botAdminRoles.length; i++) { + des += `\n> <@&${GuildDB.botAdminRoles[i]}>`; + } + botAdminRolesEmbed.setDescription(des); + + return interaction.send({ embeds: [botAdminRolesEmbed] }); + + } + + case 'admin_ping_role': + 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); + }); + + const successSetAdminRoleEmbed = new EmbedBuilder() + .setDescription(`Successfully set <@&${args[0].options[0].value}> as the server admin role..`) + .setColor(client.config.Colors.Green); + + return interaction.send({ embeds: [successSetAdminRoleEmbed] }); + + case 'exclude': + const exclude_config = args[0].options[0].name; + const exclude_roleid = ['add', 'remove'].includes(exclude_config) ? args[0].options[0].options[0].value : null; + + if (exclude_config == 'add') { + client.dbo.collection('guilds').updateOne({'server.serverID': GuildDB.serverID}, {$push: {'server.excludedRoles': exclude_roleid}}, (err, res) => { + if (err) return client.sendInternalError(interaction, err); + }) + + const successExcludeEmbed = new EmbedBuilder() + .setColor(client.config.Colors.Green) + .setDescription(`**Done!**\n> Successfully added <@&${exclude_roleid}> to list of excluded roles.`) + + return interaction.send({ embeds: [successExcludeEmbed] }); + + } else if (exclude_config == 'remove') { + client.dbo.collection('guilds').updateOne({'server.serverID': GuildDB.serverID}, {$pull: {'server.excludedRoles': exclude_roleid}}, (err, res) => { + if (err) return client.sendInternalError(interaction, err); + }) + + const successRemoveExcludeEmbed = new EmbedBuilder() + .setColor(client.config.Colors.Green) + .setDescription(`**Done!**\n> Successfully removed <@&${exclude_roleid}> to list of excluded roles.`) + + return interaction.send({ embeds: [successRemoveExcludeEmbed] }); + + } else if (exclude_config == "view") { + + if (GuildDB.excludedRoles.length == 0) { + const noExcludedRoles = new EmbedBuilder() + .setColor(client.config.Colors.Default) + .setTitle('Excluded Roles') + .setDescription('> There have been no excluded roles'); + + return interaction.send({ embeds: [noExcludedRoles] }); + } + + const excludedRolesEmbed = new EmbedBuilder() + .setColor(client.config.Colors.Default) + .setTitle('Excluded Roles') + + let des = ''; + for (let i = 0; i < GuildDB.excludedRoles.length; i++) { + des += `\n> <@&${GuildDB.excludedRoles[i]}>`; + } + excludedRolesEmbed.setDescription(des); + + return interaction.send({ embeds: [excludedRolesEmbed] }); + + } + + case 'reset': + const promptReset = new EmbedBuilder() + .setTitle(`Woah!? Hold on.`) + .setDescription('Are you sure you wish to remove all your configurations for this guild?') + .setColor(client.config.Colors.Default) + + const optReset = new ActionRowBuilder() + .addComponents( + new ButtonBuilder() + .setCustomId(`ResetSettings-yes-${interaction.member.user.id}`) + .setLabel("Yes") + .setStyle(ButtonStyle.Danger), + new ButtonBuilder() + .setCustomId(`ResetSettings-no-${interaction.member.user.id}`) + .setLabel("No") + .setStyle(ButtonStyle.Success) + ) + + return interaction.send({ embeds: [promptReset], components: [optReset], flags: (1 << 6) }); + + case 'view': + + // wrappers + const w = "\`\`\`"; + const a = "ansi\n"; + const f = "fix\n"; + const m = "arm\n" + const g = ""; + const r = ""; + + // boolean display + const autoRestart = GuildDB.autoRestart ? `${g}true` : `${r}false`; + const showKillfeedCoords = GuildDB.showKillfeedCoords ? `${g}true` : `${r}false`; + const showKillfeedWeapon = GuildDB.showKillfeedWeapon ? `${g}true` : `${r}false`; + const purchaseUAV = GuildDB.purchaseUAV ? `${g}true` : `${r}false`; + const purchaseEMP = GuildDB.purchaseEMP ? `${g}true` : `${r}false`; + const adminRoles = GuildDB.hasBotAdmin ? `${g}true` : `${r}false` + const excludedRoles = GuildDB.hasExcludedRoles ? `${g}true` : `${r}false`; + + // Role / channel display + const NONE = `${w}${m}none${w}`; + const channelsInfo = GuildDB.customChannelStatus ? '\`\` to view' : NONE; + const killfeedChannel = client.exists(GuildDB.killfeedChannel) ? `<#${GuildDB.killfeedChannel}>` : NONE; + const connectionLogs = client.exists(GuildDB.connectionLogsChannel) ? `<#${GuildDB.connectionLogsChannel}>` : NONE; + const activePlayers = client.exists(GuildDB.activePlayersChannel) ? `<#${GuildDB.activePlayersChannel}>` : NONE; + const welcomeChannel = client.exists(GuildDB.welcomeChannel) ? `<#${GuildDB.welcomeChannel}>` : NONE; + const linkedGTRole = client.exists(GuildDB.linkedGamertagRole) ? `<@&${GuildDB.linkedGamertagRole}>` : NONE; + const memberRole = client.exists(GuildDB.memberRole) ? `<@&${GuildDB.memberRole}>` : NONE; + + // value display + const incomeLimiter = `${GuildDB.incomeLimiter} hours`; + const startingBalance = `$${GuildDB.startingBalance.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2})}`; + const uavPrice = `$${GuildDB.uavPrice.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2})}`; + const empPrice = `$${GuildDB.empPrice.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2})}`; + const combatLogTimer = `${GuildDB.combatLogTimer} minutes`; + + // Ugly below but kinda nice above + const settingsEmbed = new EmbedBuilder() + .setColor(client.config.Colors.Default) + .setTitle('Current Guild Configurations') + .addFields( + { name: 'Guild ID', value: `${w}${f}${GuildDB.serverID}${w}`, inline: true }, + { name: 'Server Name', value: `${w}${f}${GuildDB.serverName}${w}`, inline: true }, + { name: 'Auto Restart', value: `${w}${a}${autoRestart}${w}`, inline: true }, + { name: 'UAVs Enabled', value: `${w}${a}${purchaseUAV}${w}`, inline: true }, + { name: 'EMPs Enabled', value: `${w}${a}${purchaseEMP}${w}`, inline: true }, + { name: 'Show Killfeed Coords', value: `${w}${a}${showKillfeedCoords}${w}`, inline: true }, + { name: 'Show Killfeed Weapons', value: `${w}${a}${showKillfeedWeapon}${w}`, inline: true }, + { name: 'Has Admin Rols', value: `${w}${a}${adminRoles}${w}`, inline: true }, + { name: 'Has Excluded Roles', value: `${w}${a}${excludedRoles}${w}`, inline: true }, + { name: 'Allowed Channels', value: `${channelsInfo}`, inline: true }, + { name: 'Killfeed Channel', value: `${killfeedChannel}`, inline: true }, + { name: 'Connection Logs Channel', value: `${connectionLogs}`, inline: true }, + { name: 'Player List Channel', value: `${activePlayers}`, inline: true }, + { name: 'Welcome Channel', value: `${welcomeChannel}`, inline: true }, + { name: 'Linked Gamertag Role', value: `${linkedGTRole}`, inline: true }, + { name: 'Member Role', value: `${memberRole}`, inline: true }, + { name: 'Income Limiter', value: `${w}${f}${incomeLimiter}${w}`, inline: true }, + { name: 'Starting Balance', value: `${w}${f}${startingBalance}${w}`, inline: true }, + { name: 'UAV Price', value: `${w}${f}${uavPrice}${w}`, inline: true }, + { name: 'EMP Price', value: `${w}${f}${empPrice}${w}`, inline: true }, + { name: 'Combat Log Timer', value: `${w}${f}${combatLogTimer}${w}`, inline: true }, + ); + + return interaction.send({ embeds: [settingsEmbed] }); + + case 'set_channel': + const channelType = args[0].options[0].value; + const channel = args[0].options[1].value; + + client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$set: {[`server.${channelType}`]: channel}}, (err, res) => { + if (err) return client.sendInternalError(interaction, err); + }); + + const successSetChannelEmbed = new EmbedBuilder() + .setDescription(`Successfully set <#${channel}> as the ${channelType} channel.`) + .setColor(client.config.Colors.Green); + + return interaction.send({ embeds: [successSetChannelEmbed] }); + + 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}}, (err, res) => { + if (err) return client.sendInternalError(interaction, err); + }); + + const successLinkedGTRoleEmbed = new EmbedBuilder() + .setDescription(`Successfully set <@&${linked_gt_role}> to give to users who link their gamertag.`) + .setColor(client.config.Colors.Green); + + return interaction.send({ embeds: [successLinkedGTRoleEmbed] }); + + 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}}, (err, res) => { + if (err) return client.sendInternalError(interaction, err); + }); + + const successMemberRoleEmbed = new EmbedBuilder() + .setDescription(`Successfully set <@&${member_role}> to give to users who link they join.`) + .setColor(client.config.Colors.Green); + + 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}}, (err, res) => { + if (err) return client.sendInternalError(interaction, err); + }); + + let successSetStartingBalanceEmbed = new EmbedBuilder() + .setColor(client.config.Colors.Green) + .setDescription(`Successfully set $${args[0].options[0].value.toFixed(2)} as starting balance`); + + return interaction.send({ embeds: [successSetStartingBalanceEmbed] }); + + case 'income_role': + if (args[0].options[0].name== 'set') { + const incomeRoleId = args[0].options[0].options[0].value + + if (args[0].options[0].options[1].value <= 0) { + let errorIncomeAmount = new EmbedBuilder() + .setDescription('**Error Notice:** Amount cannot be $0 or less than $0.') + .setColor(client.config.Colors.Red); + + return interaction.send({ embeds: [errorIncomeAmount] }); + } + + const searchIndex = GuildDB.incomeRoles.findIndex((role) => role.role==incomeRoleId); + if (searchIndex == -1) { + const newIncome = { + role: incomeRoleId, + income: args[0].options[0].options[1].value, + } + + client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$push: {"server.incomeRoles":newIncome}}, (err, res) => { + if (err) return client.sendInternalError(interaction, err); + }); + } else { + client.dbo.collection("guilds").updateOne({ + "server.serverID": GuildDB.serverID, + "server.incomeRoles.role": incomeRoleId + }, + { + $set: { + "server.incomeRoles.$.income": args[0].options[0].options[1].value + } + }, (err, res) => { + if (err) return client.sendInternalError(interaction, err); + }); + } + const perform = searchIndex == -1 ? 'set' : 'updated'; + + const successIncomeRoleEmbed = new EmbedBuilder() + .setDescription(`Successfully ${perform} <@&${incomeRoleId}>'s income to $${args[0].options[0].options[1].value}`) + .setColor(client.config.Colors.Green); + + return interaction.send({ embeds: [successIncomeRoleEmbed] }); + + } else if (args[0].options[0].name== 'remove') { + const searchIndex = GuildDB.incomeRoles.findIndex((role) => role.role==incomeRoleId); + if (searchIndex == -1) { + const errorIncomeNotFoundEmbed = new EmbedBuilder() + .setDescription('**Error Notice:** Role not found') + .setColor(client.config.Colors.Red); + + return interaction.send({ embeds: [errorIncomeNotFoundEmbed] }); + } else { + const promptRemoveIncomeRole = new EmbedBuilder() + .setTitle(`Are you sure you want to remove this role as an income?`) + .setColor(client.config.Colors.Default) + + const optRemoveIncomeRole = new ActionRowBuilder() + .addComponents( + new ButtonBuilder() + .setCustomId(`RemoveIncomeRole-yes-${incomeRoleId}-${interaction.member.user.id}`) + .setLabel("Yes") + .setStyle(ButtonStyle.Danger), + new ButtonBuilder() + .setCustomId(`RemoveIncomeRole-no-${incomeRoleId}-${interaction.member.user.id}`) + .setLabel("No") + .setStyle(ButtonStyle.Success) + ) + + return interaction.send({ embeds: [promptRemoveIncomeRole], components: [optRemoveIncomeRole], flags: (1 << 6) }); + } + } + + case 'income_limiter': + 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); + }); + + let successIncomeLimiterEmbed = new EmbedBuilder() + .setColor(client.config.Colors.Green) + .setDescription(`Successfully set **${args[0].options[0].value} hours** as the wait time to collect income.`); + + 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}}, (err, res) => { + if (err) return client.sendInternalError(interaction, err); + }); + + let successUAVPriceEmbed = new EmbedBuilder() + .setColor(client.config.Colors.Green) + .setDescription(`Successfully set $${args[0].options[0].value.toFixed(2)} as UAV price`); + + 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}}, (err, res) => { + if (err) return client.sendInternalError(interaction, err); + }); + + let successEMPPriceEmbed = new EmbedBuilder() + .setColor(client.config.Colors.Green) + .setDescription(`Successfully set $${args[0].options[0].value.toFixed(2)} as EMP price`); + + return interaction.send({ embeds: [successEMPPriceEmbed] }); + + case 'combat-log-timer': + client.dbo.collection("guilds").updateOne({"server.serverID": GuildDB.serverID}, {$set: {"server.combatLogTimer":args[0].options[0].value}}, (err, res) => { + if (err) return client.sendInternalError(interaction, err); + }); + + let successCobatLogTimerEmbed = new EmbedBuilder() + .setColor(client.config.Colors.Green) + .setDescription(`Successfully set combat log timer to **${args[0].options[0].value.toFixed(0)} minutes.**`); + + return interaction.send({ embeds: [successCobatLogTimerEmbed] }); + + case 'toggle-uav-purchase': + const togggleUAVpurchase = args[0].options[0].value ? 1 : 0; + + client.dbo.collection("guilds").updateOne({"server.serverID": GuildDB.serverID}, {$set: {"server.purchaseUAV": togggleUAVpurchase}}, (err, res) => { + if (err) return client.sendInternalError(interaction, err); + }); + + let successToggleUAVpurchaseEmbed = new EmbedBuilder() + .setColor(client.config.Colors.Green) + .setDescription(`Users can ${togggleUAVpurchase ? 'now' : 'no longer'} purchase UAVs.`); + + return interaction.send({ embeds: [successToggleUAVpurchaseEmbed] }); + + case 'toggle-emp-purchase': + const togggleEMPpurchase = args[0].options[0].value ? 1 : 0; + + client.dbo.collection("guilds").updateOne({"server.serverID": GuildDB.serverID}, {$set: {"server.purchaseEMP": togggleEMPpurchase}}, (err, res) => { + if (err) return client.sendInternalError(interaction, err); + }); + + let successToggleEMPpurchaseEmbed = new EmbedBuilder() + .setColor(client.config.Colors.Green) + .setDescription(`Users can ${togggleUAVpurchase ? 'now' : 'no longer'} purchase EMPs.`); + + return interaction.send({ embeds: [successToggleEMPpurchaseEmbed] }); + + case 'killfeed': + const killfeed_configuration = args[0].options[0].name; + + if (killfeed_configuration == 'channel') { + + const channel = args[0].options[0].options[0].value; + + client.dbo.collection("guilds").updateOne({"server.serverID": GuildDB.serverID},{$set: {'server.killfeedChannel': channel}}, (err, res) => { + if (err) return client.sendInternalError(interaction, err); + }); + + const successConfigureKillfeedChannel = new EmbedBuilder() + .setColor(client.config.Colors.Green) + .setDescription(`Successfully configured the killfeed channel to <#${channel}>`); + + return interaction.send({ embeds: [successConfigureKillfeedChannel] }); + + } else if (killfeed_configuration == 'show_coords') { + const showKillfeedCoordsConfiguration = args[0].options[0].options[0].value ? 1 : 0; + + client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$set: {"server.showKillfeedCoords": showKillfeedCoordsConfiguration}}, (err, res) => { + if (err) return client.sendInternalError(interaction, err); + }); + + const successConfigureShowKillfeedCoords = new EmbedBuilder() + .setDescription(`Successfully configured the killfeed to ${showKillfeedCoordsConfiguration ? 'show' : 'not show'} coordinates.`) + .setColor(client.config.Colors.Green); + + return interaction.send({ embeds: [successConfigureShowKillfeedCoords] }); + + } else if (killfeed_configuration == 'show_weapon') { + + const showKillfeedWeaponConfiguration = args[0].options[0].options[0].value ? 1 : 0; + + client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$set: {"server.showKillfeedWeapon": showKillfeedWeaponConfiguration}}, (err, res) => { + if (err) return client.sendInternalError(interaction, err); + }); + + const successConfigureShowKillfeedCoords = new EmbedBuilder() + .setDescription(`Successfully configured the killfeed to ${showKillfeedWeaponConfiguration ? 'show' : 'not show'} weapon icons.`) + .setColor(client.config.Colors.Green); + + return interaction.send({ embeds: [successConfigureShowKillfeedCoords] }); + + } + + case 'welcome_message_server_name': + const server_name = args[0].options[0].value; + + client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$set: {"server.serverName":server_name}}, (err, res) => { + if (err) return client.sendInternalError(interacion, err); + }); + + const succcessUpdateServerName = new EmbedBuilder() + .setDescription(`Successfully configured the server name to **${server_name}** in the welcome message.`) + .setColor(client.config.Colors.Green); + + return interaction.send({ embeds: [succcessUpdateServerName] }); + + default: + return client.sendInternalError(interaction, 'There was an error parsing the config command'); + } + }, + }, + + Interactions: { + + RemoveAllowedChannels: { + run: async (client, interaction, GuildDB) => { + if (!interaction.customId.endsWith(interaction.member.user.id)) { + return interaction.reply({ + content: "This button is not for you", + flags: (1 << 6) + }) + } + let action = '' + if (interaction.customId.split('-')[1]=='yes') { + action = 'removed'; + client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$pull:{"server.allowedChannels": interaction.customId.split('-')[2]}}, (err, res) => { + if (err) return client.sendInternalError(interaction, err); + }); + } else if (interaction.customId.split('-')[1]=='no') action = 'kept'; + + const successEmbed = new EmbedBuilder() + .setColor(client.config.Colors.Green) + .setTitle(`**Success**\n> Successfullly ${action} the channel.`) + + return interaction.update({ embeds: [successEmbed], components: [] }); + } + }, + + ClearAllowedChannels: { + run: async (client, interaction, GuildDB) => { + if (!interaction.customId.endsWith(interaction.member.user.id)) { + return interaction.reply({ + content: "This buttpm is not for you", + flags: (1 << 6) + }); + } + let action; + if (interaction.customId.split('-')[1] == 'yes') { + action = 'cleared'; + client.dbo.collection("guilds").updateOne({"server.serverID": GuildDB.serverID}, {$set:{"server.allowedChannels":[]}}, (err, res) => { + if (err) return client.sendInternalError(interaction, err); + }) + } else if (interaction.customId.split('-')[1] == 'no') action = 'kept'; + + const successEmbed = new EmbedBuilder() + .setColor(client.config.Colors.Green) + .setTitle(`**Success**\n> Successfully ${action} all configured channels.`); + + return interaction.update({ embeds: [successEmbed], components: [] }); + } + }, + + RemoveBotAdminRole: { + run: async (client, interaction, GuildDB) => { + if (!interaction.customId.endsWith(interaction.member.user.id)) { + return ButtonInteraction.reply({ + content: "This button is not for you", + flags: (1 << 6) + }) + } + let action = ''; + 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}}, (err, res) => { + if (err) return client.sendInternalError(interaction, err); + }); + } else if (interaction.customId.split('-')[1]=='no') action = 'kept'; + + const successEmbed = new EmbedBuilder() + .setColor(client.config.Colors.Green) + .setDescription(`**Successfully ${action} <@&${roleId}> as the bot admin role.**`) + + return interaction.update({ embeds: [successEmbed], components: [] }); + } + }, + + RemoveIncomeRole: { + run: async (client, interaction, GuildDB) => { + if (!interaction.customId.endsWith(interaction.member.user.id)) { + return ButtonInteraction.reply({ + content: "This button is not for you", + flags: (1 << 6) + }) + } + let action = ''; + let roleId = interaction.customId.split('-')[2]; + 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}}, (err, res) => { + if (err) return client.sendInternalError(interaction, err); + }); + } else if (interaction.customId.split('-')[1]=='no') action = 'kept'; + + const successEmbed = new EmbedBuilder() + .setColor(client.config.Colors.Green) + .setDescription(`**Successfully ${action} <@&${roleId}> as an income role.**`) + + return interaction.update({ embeds: [successEmbed], components: [] }); + } + }, + + ResetSettings: { + run: async (client, interaction, GuildDB) => { + if (!interaction.customId.endsWith(interaction.member.user.id)) { + return ButtonInteraction.reply({ + content: "This button is not for you", + flags: (1 << 6) + }) + } + let action = ''; + if (interaction.customId.split('-')[1]=='yes') { + action = 'reset'; + const defaultGuildConfig = getDefaultSettings(GuildDB.serverID); + 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'; + + const successEmbed = new EmbedBuilder() + .setColor(client.config.Colors.Green) + .setTitle(`Successfully ${action} guild configurations.`) + + return interaction.update({ embeds: [successEmbed], components: [] }); + } + } + } +} diff --git a/commands/event.js b/commands/event.js index 0ef13d7..e6fd9c4 100644 --- a/commands/event.js +++ b/commands/event.js @@ -31,7 +31,7 @@ module.exports = { type: CommandOptions.Integer, required: true, choices: [ - { name: '10-minutes', value: 10 }, { name: '15-minutes', value: 15 }, { name: '20-minutes', value: 20 }, { name: '25-minutes', value: 25 }, + { name: '10-minutes', value: 10 }, { name: '15-minutes', value: 15 }, { name: '20-minutes', value: 20 }, { name: '25-minutes', value: 25 }, { name: '30-minutes', value: 30 }, { name: '60-minutes', value: 60 }, { name: '90-minutes', value: 90 }, { name: '120-minutes', value: 120 }, ] }, @@ -134,7 +134,7 @@ module.exports = { value: GuildDB.events[i].name }); } - + const eventsOptions = new ActionRowBuilder().addComponents(events); return interaction.send({ components: [eventsOptions], flags: (1 << 6) }); @@ -146,7 +146,7 @@ module.exports = { DeleteEvent: { run: async(client, interaction, GuildDB) => { - if (!interaction.customId.endsWith(interaction.member.user.id)) + if (!interaction.customId.endsWith(interaction.member.user.id)) return interaction.reply({ content: 'This interaction is not for you', flags: (1 << 6) }); let event = GuildDB.events.find(e => e.name == interaction.values[0]); @@ -162,9 +162,9 @@ module.exports = { let successEmbed = new EmbedBuilder() .setColor(client.config.Colors.Green) .setDescription(`**Success:** Successfully Deleted **${event.name} Event**`); - + return interaction.update({ embeds: [successEmbed], components: [] }); } } } -} \ No newline at end of file +} diff --git a/commands/factions.js b/commands/factions.js index 11c7460..50d9faa 100644 --- a/commands/factions.js +++ b/commands/factions.js @@ -29,15 +29,15 @@ module.exports = { */ run: async (client, interaction, args, { GuildDB }) => { if (GuildDB.customChannelStatus==true&&!GuildDB.allowedChannels.includes(interaction.channel_id)) - return interaction.send({ content: `You are not allowed to use the bot in this channel.`, flags: (1 << 6) }); - + return interaction.send({ content: `You are not allowed to use the bot in this channel.`, flags: (1 << 6) }); + // Return list of factions and their armband. if (!args) { let factions = new EmbedBuilder() .setColor(client.config.Colors.Default) .setTitle('Factions & Armbands') - + let description = ''; if (GuildDB.usedArmbands.length == 0) { @@ -48,9 +48,9 @@ module.exports = { else description += `\n> <@&${factionID}> - *${data.armband}*`; } } - + factions.setDescription(description); - + return interaction.send({ embeds: [factions] }); } diff --git a/commands/gamertag-link.js b/commands/gamertag-link.js index a078952..64964bb 100644 --- a/commands/gamertag-link.js +++ b/commands/gamertag-link.js @@ -44,7 +44,7 @@ module.exports = { const warnGTOverwrite = new EmbedBuilder() .setColor(client.config.Colors.Yellow) .setDescription(`**Notice:**\n> The gamertag has previously been linked to <@${playerStat.discordID}>. Are you sure you would like to change this?`) - + const opt = new ActionRowBuilder() .addComponents( new ButtonBuilder() @@ -61,7 +61,7 @@ module.exports = { } playerStat.discordID = interaction.member.user.id; - + await UpdatePlayer(client, playerStat, interaction); let member = interaction.guild.members.cache.get(interaction.member.user.id); @@ -87,14 +87,14 @@ module.exports = { OverwriteGamertag: { run: async(client, interaction, GuildDB) => { - if (!interaction.customId.endsWith(interaction.member.user.id)) + if (!interaction.customId.endsWith(interaction.member.user.id)) return interaction.reply({ content: 'This interaction is not for you', flags: (1 << 6) }); if (interaction.customId.split('-')[1]=='yes') { let playerStat = await client.dbo.collection("players").findOne({"gamertag": interaction.customId.split('-')[2]}); playerStat.discordID = interaction.member.user.id; - + await UpdatePlayer(client, playerStat, interaction); let member = interaction.guild.members.cache.get(interaction.member.user.id); @@ -123,6 +123,6 @@ module.exports = { } } } - + } -} \ No newline at end of file +} diff --git a/commands/gamertag-unlink.js b/commands/gamertag-unlink.js index b52b6f8..a51f6a3 100644 --- a/commands/gamertag-unlink.js +++ b/commands/gamertag-unlink.js @@ -35,7 +35,7 @@ module.exports = { const warnGTOverwrite = new EmbedBuilder() .setColor(client.config.Colors.Yellow) .setDescription(`**Notice:**\n> Are you sure you want to unlink your gamertag? This will limit some automatic features.`); - + const opt = new ActionRowBuilder() .addComponents( new ButtonBuilder() @@ -56,14 +56,14 @@ module.exports = { UnlinkGamertag: { run: async(client, interaction, GuildDB) => { - if (!interaction.customId.endsWith(interaction.member.user.id)) + if (!interaction.customId.endsWith(interaction.member.user.id)) return interaction.reply({ content: 'This interaction is not for you', flags: (1 << 6) }); if (interaction.customId.split('-')[1]=='yes') { let playerStat = await client.dbo.collection("players").findOne({"discordID": interaction.member.user.id}); playerStat.discordID = ""; - + await UpdatePlayer(client, playerStat, interaction); let connectedEmbed = new EmbedBuilder() @@ -82,4 +82,4 @@ module.exports = { } } } -} \ No newline at end of file +} diff --git a/commands/help.js b/commands/help.js index a0d6d1e..efc8514 100644 --- a/commands/help.js +++ b/commands/help.js @@ -32,7 +32,7 @@ module.exports = { value: "support", type: CommandOptions.SubCommand, }, - { + { name: "credits", description: "DayZ.R Bot Credits", value: "credits", @@ -58,15 +58,15 @@ module.exports = { if (args[0].name == 'commands') { let Commands = client.commands.filter((cmd) => { return !cmd.debug - }).map((cmd) => + }).map((cmd) => `\`/${cmd.name}${cmd.usage ? " " + cmd.usage : ""}\` - ${cmd.description}` ); - + let Embed = new EmbedBuilder() .setTitle('Commands') .setColor(client.config.Colors.Default) .setDescription(`${Commands.join("\n")} - + DayZR Bot Version: v${client.config.Version}`); if (!args[0].options[0]) return interaction.send({ embeds: [Embed] }); else { @@ -77,7 +77,7 @@ module.exports = { ); if (!cmd) return interaction.send({ content: `❌ | Unable to find that command.` }); - + let embed = new EmbedBuilder() .setDescription(cmd.description) .setColor(client.config.Colors.Green) @@ -85,7 +85,7 @@ module.exports = { if (cmd.SlashCommand.options && cmd.SlashCommand.options[0].type == 1) { let description = `${cmd.description}\n\n**Usage**\n`; - + for (let i = 0; i < cmd.SlashCommand.options.length; i++) { if (cmd.SlashCommand.options[i].type == 1) { let param = ''; @@ -107,7 +107,7 @@ module.exports = { const supportEmbed = new EmbedBuilder() .setColor(client.config.Colors.Default) .setDescription(`**__DayZ.R Bot Support__** - + Are you experiencing troubles with the DayZ.R Bot? Do you have questions or concerns? Do you require help to use the bot? @@ -126,22 +126,22 @@ module.exports = { .setDescription(` **Bot Author:** mcdazzzled **Github:** https://github.com/SowinskiBraeden/dayz-reforger - + ${client.config.SupportServer} `); return interaction.send({ embeds: [creditsEmbed] }) } else if (args[0].name == 'stats') { const end = new Date().getTime(); - + const totalGuilds = await client.shard.fetchClientValues("guilds.cache.size").then(results => { return results.reduce((acc, guildCount) => acc + guildCount, 0); }); - + const totalUsers = await client.shard.broadcastEval(c => { c.guilds.cache.reduce((acc, guild) => acc + guild.memberCount, 0); }).then(data => data.reduce((acc, memberCount) => acc + memberCount, 0)); - + const stats = new EmbedBuilder() .setColor(client.config.Colors.Default) .setTitle('DayZ Reforger Bot Statistics') @@ -158,4 +158,4 @@ module.exports = { } }, }, -}; \ No newline at end of file +}; diff --git a/commands/leaderboard.js b/commands/leaderboard.js index 2931301..53ec582 100644 --- a/commands/leaderboard.js +++ b/commands/leaderboard.js @@ -21,7 +21,7 @@ module.exports = { { name: "Money", value: "money" }, { name: "Total Time Played", value: "totalSessionTime" }, { name: "Longest Game Session", value: "longestSessionTime" }, - { name: "Kills", value: "kills" }, + { name: "Kills", value: "kills" }, { name: "Kill Streak", value: "killStreak" }, { name: "Best Kill Streak", value: "bestKillStreak" }, { name: "Deaths", value: "deaths" }, @@ -60,7 +60,7 @@ module.exports = { return interaction.send({ embeds: [warnNitradoNotInitialized], flags: (1 << 6) }); } - + const category = args[0].value; const limit = args[1].value; @@ -72,28 +72,28 @@ module.exports = { ]).toArray(); } else { - + leaderboard = await client.dbo.collection("players").aggregate([ { $sort: { [`${category}`]: -1 } } ]).toArray(); } - + let leaderboardEmbed = new EmbedBuilder() .setColor(client.config.Colors.Default); - + let title = category == 'kills' ? "Total Kills Leaderboard" : category == 'killStreak' ? "Current Killstreak Leaderboard" : category == 'bestKillStreak' ? "Best Killstreak Leaderboard" : category == 'deaths' ? "Total Deaths Leaderboard" : category == 'deathStreak' ? "Current Deathstreak Leaderboard" : - category == 'worstDeathStreak' ? "Worst Deathstreak Leaderboard" : - category == 'longestKill' ? "Longest Kill Leaderboard" : - category == 'money' ? "Money Leaderboard" : - category == 'totalSessionTime' ? "Total Time Played" : - category == 'longestSessionTime' ? "Longest Game Session" : - category == 'KDR' ? "Kill Death Ratio" : - category == 'connections' ? "Times Connected" : + category == 'worstDeathStreak' ? "Worst Deathstreak Leaderboard" : + category == 'longestKill' ? "Longest Kill Leaderboard" : + category == 'money' ? "Money Leaderboard" : + category == 'totalSessionTime' ? "Total Time Played" : + category == 'longestSessionTime' ? "Longest Game Session" : + category == 'KDR' ? "Kill Death Ratio" : + category == 'connections' ? "Times Connected" : category == 'shotsLanded' ? "Shots Landed" : category == 'timesShot' ? "Times Shot" : category == 'combatRating' ? "Combat Rating" : 'N/A Error'; @@ -103,21 +103,21 @@ module.exports = { let des = ``; for (let i = 0; i < limit; i++) { if (leaderboard.length < limit && i == leaderboard.length) break; - + let stats = category == 'kills' ? `${leaderboard[i].kills} Kill${(leaderboard[i].kills>1||leaderboard[i].kills==0)?'s':''}` : category == 'killStreak' ? `${leaderboard[i].killStreak} Player Killstreak` : category == 'bestKillStreak' ? `${leaderboard[i].bestKillStreak} Player Killstreak` : category == 'deaths' ? `${leaderboard[i].deaths} Death${leaderboard[i].deaths>1||leaderboard[i].deaths==0?'s':''}` : category == 'deathStreak' ? `${leaderboard[i].deathStreak} Deathstreak` : category == 'worstDeathstreak' ? `${leaderboard[i].worstDeathStreak} Deathstreak` : - category == 'longestKill' ? `${leaderboard[i].longestKill}m` : - category == 'money' ? `$${(leaderboard[i].user.guilds[GuildDB.serverID].balance).toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2})}` : - category == 'totalSessionTime' ? `**Total:** ${client.secondsToDhms(leaderboard[i].totalSessionTime)}\n> **Last Session:** ${client.secondsToDhms(leaderboard[i].lastSessionTime)}` : - category == 'longestSessionTime' ? `**Longest Game Session:** ${client.secondsToDhms(leaderboard[i].longestSessionTime)}` : - category == 'KDR' ? `**KDR: ${leaderboard[i].KDR.toFixed(2)}**` : - category == 'connection' ? `**Connections: ${leaderboard[i].connections}**` : - category == 'combatRating' ? `**Combat Rating:** ${leaderboard[i].combatRating}` : - category == 'shotsLanded' ? `**Shots Landed:** ${leaderboard[i].shotsLanded}` : + category == 'longestKill' ? `${leaderboard[i].longestKill}m` : + category == 'money' ? `$${(leaderboard[i].user.guilds[GuildDB.serverID].balance).toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2})}` : + category == 'totalSessionTime' ? `**Total:** ${client.secondsToDhms(leaderboard[i].totalSessionTime)}\n> **Last Session:** ${client.secondsToDhms(leaderboard[i].lastSessionTime)}` : + category == 'longestSessionTime' ? `**Longest Game Session:** ${client.secondsToDhms(leaderboard[i].longestSessionTime)}` : + category == 'KDR' ? `**KDR: ${leaderboard[i].KDR.toFixed(2)}**` : + category == 'connection' ? `**Connections: ${leaderboard[i].connections}**` : + category == 'combatRating' ? `**Combat Rating:** ${leaderboard[i].combatRating}` : + category == 'shotsLanded' ? `**Shots Landed:** ${leaderboard[i].shotsLanded}` : category == 'timesShot' ? `**Times Shot:** ${leaderboard[i].timesShot}` : 'N/A Error'; if (category == 'money') des += `**${i+1}.** <@${leaderboard[i].user.userID}> - **${stats}**\n` @@ -128,7 +128,7 @@ module.exports = { } if (['money', 'totalSessionTime', 'longestSessionTime', 'combatRating'].includes(category)) leaderboardEmbed.setDescription(des); - + return interaction.send({ embeds: [leaderboardEmbed] }); }, }, diff --git a/commands/location.js b/commands/location.js index 2c4e3e6..f143ca4 100644 --- a/commands/location.js +++ b/commands/location.js @@ -37,14 +37,14 @@ module.exports = { let newDt = await client.getDateEST(playerStat.time); let unixTime = Math.floor(newDt.getTime()/1000); - + const destination = nearest(playerStat.pos, GuildDB.Nitrado.Mission); - + let lastLocation = new EmbedBuilder() .setColor(client.config.Colors.Default) .setDescription(`**Location - **\nYour last location was detected at **[${playerStat.pos[0]}, ${playerStat.pos[1]}](https://www.izurvive.com/chernarusplussatmap/#location=${playerStat.pos[0]};${playerStat.pos[1]})**\n${destination}`) - + return interaction.send({ embeds: [lastLocation], flags: (1 << 6) }); }, }, -} \ No newline at end of file +} diff --git a/commands/lookup.js b/commands/lookup.js index 9c23e42..044ec63 100644 --- a/commands/lookup.js +++ b/commands/lookup.js @@ -58,19 +58,19 @@ module.exports = { let playerStat = await client.dbo.collection("players").findOne({"gamertag": args[0].options[0].value}); if (playerStat == undefined) return interaction.send({ embeds: [new EmbedBuilder().setColor(client.config.Colors.Yellow).setDescription(`**Not Found** This gamertag \` ${args[0].options[0].value} \` cannot be found, the gamertag may be incorrect or this player has not logged onto the server before for at least \` 5 minutes \`.`)] }); - + if (client.exists(playerStat.discordID)) { const found = new EmbedBuilder() .setColor(client.config.Colors.Yellow) .setDescription(`**Record Found**\n> The gamertag \` ${playerStat.gamertag} \` is currently linked to <@${playerStat.discordID}>.`) - + return interaction.send({ embeds: [found] }); } - + let notFound = new EmbedBuilder() .setColor(client.config.Colors.Default) .setDescription(`**Record Not Found**\n The gamertag \` ${playerStat.gamertag} \` currently has no linked Discord account.`); - + return interaction.send({ embeds: [notFound] }) } else if (args[0].name == 'gamertag') { @@ -81,10 +81,10 @@ module.exports = { const found = new EmbedBuilder() .setColor(client.config.Colors.Yellow) .setDescription(`**Record Found**\n> The user <@${playerStat.discordID}> has linked the gamertag \` ${playerStat.gamertag} \`.`) - + return interaction.send({ embeds: [found] }); } }, }, -} \ No newline at end of file +} diff --git a/commands/player-list.js b/commands/player-list.js index 25b3307..db6f23f 100644 --- a/commands/player-list.js +++ b/commands/player-list.js @@ -12,7 +12,7 @@ module.exports = { channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"], member: [], }, - options: [], + options: [], SlashCommand: { /** * @@ -35,7 +35,7 @@ module.exports = { const data = await FetchServerSettings(GuildDB.Nitrado, client, 'commands/player-list.js'); // Fetch server status const e = data && data !== 1; // Check if data exists - + const hostname = e ? data.data.gameserver.settings.config.hostname : 'N/A'; const map = e ? Missions[data.data.gameserver.settings.config.mission] : 'N/A'; const status = e ? data.data.gameserver.status : 'N/A'; @@ -57,7 +57,7 @@ module.exports = { for (let i = 0; i < activePlayers.length; i++) { des += `**- ${activePlayers[i].gamertag}**\n`; } - + const nodes = activePlayers.length === 0; const serverEmbed = new EmbedBuilder() .setColor(client.config.Colors.Default) @@ -78,4 +78,4 @@ module.exports = { return interaction.editReply({ embeds: [serverEmbed, activePlayersEmbed] }); }, }, -} \ No newline at end of file +} diff --git a/commands/player-stats.js b/commands/player-stats.js index 9d67edb..bffc1b3 100644 --- a/commands/player-stats.js +++ b/commands/player-stats.js @@ -22,7 +22,7 @@ module.exports = { { name: "Money", value: "money" }, { name: "Total Time Played", value: "totalSessionTime" }, { name: "Longest Game Session", value: "longestSessionTime" }, - { name: "Kills", value: "kills" }, + { name: "Kills", value: "kills" }, { name: "Kill Streak", value: "killStreak" }, { name: "Best Kill Streak", value: "bestKillStreak" }, { name: "Deaths", value: "deaths" }, @@ -56,7 +56,7 @@ module.exports = { * @param {*} param3 */ run: async (client, interaction, args, { GuildDB }, start) => { - + if (!client.exists(GuildDB.Nitrado) || !client.exists(GuildDB.Nitrado.ServerID) || !client.exists(GuildDB.Nitrado.UserID) || !client.exists(GuildDB.Nitrado.Auth)) { const warnNitradoNotInitialized = new EmbedBuilder() .setColor(client.config.Colors.Yellow) @@ -69,7 +69,7 @@ module.exports = { let discord = args[1] && args[1].name == 'discord' ? args[1].value : undefined; let gamertag = args[1] && args[1].name == 'gamertag' ? args[1].value : undefined; let self = !discord && !gamertag; // searching for self if both discord and gamertag are undefined; - + let query; let leaderboard; let leaderboardPos; @@ -88,7 +88,7 @@ module.exports = { leaderboardPos = leaderboard.indexOf(query); } else { - + leaderboard = await client.dbo.collection("players").aggregate([ { $sort: { [`${category}`]: -1 } } ]).toArray(); @@ -108,13 +108,13 @@ module.exports = { category == 'bestkillStreak' ? "Best Killstreak" : category == 'deaths' ? "Total Deaths" : category == 'deathStreak' ? "Current Deathstreak" : - category == 'worstDeathStreak' ? "Worst Deathstreak" : - category == 'longestKill' ? "Longest Kill" : - category == 'money' ? "Total Money" : + category == 'worstDeathStreak' ? "Worst Deathstreak" : + category == 'longestKill' ? "Longest Kill" : + category == 'money' ? "Total Money" : category == 'totalSessionTime' ? "Total Time Played" : category == 'longestSessionTime' ? "Longest Game Session" : category == 'KDR' ? "Kill Death Ratio" : - category == 'connections' ? "Times Connected" : + category == 'connections' ? "Times Connected" : category == 'shotsLanded' ? "Shots Landed" : category == 'timesShot' ? "Times Shot" : category == 'combatRating' ? "Combat Rating" : 'N/A Error'; @@ -134,14 +134,14 @@ module.exports = { category == 'deaths' ? `${query.deaths} Death${query.deaths>1||query.deaths==0?'s':''}` : category == 'deathStreak' ? `${query.deathStreak} Deathstreak` : category == 'worstDeathStreak' ? `${query.worstDeathStreak} Deathstreak` : - category == 'longestKill' ? `${query.longestKill}m` : - category == 'money' ? `$${(query.user.guilds[GuildDB.serverID].balance).toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2})}` : - category == 'KDR' ? `${query.KDR.toFixed(2)} KDR` : - category == 'connections' ? `${query.connections} connections` : + category == 'longestKill' ? `${query.longestKill}m` : + category == 'money' ? `$${(query.user.guilds[GuildDB.serverID].balance).toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2})}` : + category == 'KDR' ? `${query.KDR.toFixed(2)} KDR` : + category == 'connections' ? `${query.connections} connections` : category == 'combatRating' ? `${query.combatRating}` : 'N/A Error'; statsEmbed.addFields({ name: 'Leaderboard Position', value: `# ${leaderboardPos}`, inline: true }); - + if ((category == 'shotsLanded' || category == 'timesShot') && !client.exists(query.shotsLanded)) query = insertPVPstats(query); if (category == 'totalSessionTime') { @@ -154,11 +154,11 @@ module.exports = { { name: 'Longest Game Session', value: client.secondsToDhms(query.longestSessionTime), inline: true }, { name: 'Last Session Time', value: client.secondsToDhms(query.lastSessionTime), inline: true } ); - } else if (category == 'shotsLanded') { + } else if (category == 'shotsLanded') { statsEmbed.addFields( { name: 'Total Shots Landed', value: `${query.shotsLanded}`, inline: true }, { name: 'View Weapon stats', value: ``, inline: true } - ); + ); const chart = { type: 'bar', @@ -189,18 +189,18 @@ module.exports = { }, }, }; - + const encodedChart = encodeURIComponent(JSON.stringify(chart)); const chartURL = `https://quickchart.io/chart?bkg=${encodeURIComponent("#ded8d7")}&c=${encodedChart}`; - + statsEmbed.setImage(chartURL); - } else if (category == 'timesShot') { + } else if (category == 'timesShot') { statsEmbed.addFields( { name: 'Total Times Shot', value: `${query.timesShot}`, inline: true }, { name: 'View Weapon stats', value: ``, inline: true }, ); - + const chart = { type: 'bar', data: { @@ -230,12 +230,12 @@ module.exports = { }, }, }; - + const encodedChart = encodeURIComponent(JSON.stringify(chart)); const chartURL = `https://quickchart.io/chart?bkg=${encodeURIComponent("#ded8d7")}&c=${encodedChart}`; - + statsEmbed.setImage(chartURL); - + } else if (category == 'combatRating') { let data = query.combatRatingHistory; @@ -318,8 +318,8 @@ module.exports = { statsEmbed.setImage(chartURL); } else statsEmbed.addFields({ name: title, value: stats, inline: true }); - + return interaction.send({ embeds: [statsEmbed] }); }, }, -} \ No newline at end of file +} diff --git a/commands/purchase-emp.js b/commands/purchase-emp.js index a13ee40..137ccad 100644 --- a/commands/purchase-emp.js +++ b/commands/purchase-emp.js @@ -11,7 +11,7 @@ module.exports = { permissions: { channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"], member: ["MANAGE_GUILD"], - }, + }, options: [{ name: "duration", description: "Select the duration of the emp (30 or 60 minutes)", @@ -32,7 +32,7 @@ module.exports = { * @param {*} param3 */ run: async (client, interaction, args, { GuildDB }) => { - + if (!client.exists(GuildDB.Nitrado) || !client.exists(GuildDB.Nitrado.ServerID) || !client.exists(GuildDB.Nitrado.UserID) || !client.exists(GuildDB.Nitrado.Auth)) { const warnNitradoNotInitialized = new EmbedBuilder() .setColor(client.config.Colors.Yellow) @@ -45,7 +45,7 @@ module.exports = { const duration = args[0].value; let banking = await client.dbo.collection("users").findOne({"user.userID": interaction.member.user.id}).then(banking => banking); - + if (!banking) { banking = await createUser(interaction.member.user.id, GuildDB.serverID, GuildDB.startingBalance, client) if (!client.exists(banking)) return client.sendInternalError(interaction, err); @@ -67,13 +67,13 @@ module.exports = { const price = duration == 30 ? GuildDB.empPrice : GuildDB.empPrice * 2; const newBalance = banking.guilds[GuildDB.serverID].balance - price; - + 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}}, (err, res) => { if (err) return client.sendInternalError(interaction, err); }); - + let alarms = new StringSelectMenuBuilder() .setCustomId(`EMPAlarmSelect-${interaction.member.user.id}`) .setPlaceholder(`Select an Alarm to EMP.`) diff --git a/commands/purchase-uav.js b/commands/purchase-uav.js index cc52779..4713729 100644 --- a/commands/purchase-uav.js +++ b/commands/purchase-uav.js @@ -39,7 +39,7 @@ module.exports = { * @param {*} param3 */ run: async (client, interaction, args, { GuildDB }) => { - + if (!client.exists(GuildDB.Nitrado) || !client.exists(GuildDB.Nitrado.ServerID) || !client.exists(GuildDB.Nitrado.UserID) || !client.exists(GuildDB.Nitrado.Auth)) { const warnNitradoNotInitialized = new EmbedBuilder() .setColor(client.config.Colors.Yellow) @@ -72,7 +72,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}}, (err, res) => { if (err) return client.sendInternalError(interaction, err); }); diff --git a/commands/reset.js b/commands/reset.js index 57b68ae..7eb2858 100644 --- a/commands/reset.js +++ b/commands/reset.js @@ -56,7 +56,7 @@ module.exports = { ) return interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) }); - + }, }, @@ -66,7 +66,7 @@ module.exports = { run: async (client, interaction, GuildDB) => { const choice = interaction.customId.split('-')[1]; const targetUserID = interaction.customId.split('-')[2]; - + if (!interaction.customId.endsWith(interaction.member.user.id)) { return interaction.reply({ content: "This button is not for you", @@ -79,7 +79,7 @@ module.exports = { .setTitle('Successfully reset user\'s data') let banking = await client.dbo.collection("users").findOne({"user.userID": interaction.member.user.id}).then(banking => banking); - + let bankingReset = false; if (!banking) bankingReset = true else banking = banking.user @@ -108,4 +108,4 @@ module.exports = { } } } -} \ No newline at end of file +} diff --git a/commands/server.js b/commands/server.js index fb66f2a..3421326 100644 --- a/commands/server.js +++ b/commands/server.js @@ -189,7 +189,7 @@ module.exports = { return interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) }); } - + if (!client.exists(GuildDB.Nitrado) || !client.exists(GuildDB.Nitrado.ServerID)) return interaction.send({ embeds: [new EmbedBuilder().setColor(client.config.Colors.Red).setDescription(`**Notice:**\nThis Discord guild has not been configured with a Nitrado DayZ server. To configure your guild, use `)] }); if (args[0].name == 'credentials-status') { @@ -263,7 +263,7 @@ module.exports = { } else if (args[0].name == "auto-restart") { let msg = 'Auto server restart periodic check enabled.'; let pref = 0; - + // Enable/Disable a 10min periodic server status check. if (!client.arIntervalIds.has(GuildDB.serverID)) { client.arIntervalIds.set(GuildDB.serverID, setInterval(CheckServerStatus, client.arInterval, GuildDB.Nitrado, client)); @@ -283,7 +283,7 @@ module.exports = { }); return interaction.send({ embeds: [new EmbedBuilder().setColor(client.config.Colors.Yellow).setDescription(msg)], flags: (1 << 6) }); - + } else if (args[0].name == 'disable-base-damage') { const preference = args[0].options[0].value; await interaction.deferReply({ flags: (1 << 6) }); @@ -292,7 +292,7 @@ module.exports = { if (disableBaseDamageFailed) return interaction.editReply({ embeds: [new EmbedBuilder().setColor(client.config.Colors.Red).setDescription('Failed to set **disableBaseDamage**. This can result from a variety of reasons:\nNitrado servers may be experiencing issues\nThe DayZ.R Bot may be experiencing issues\nYour Nitrado credentials were entered incorrectly')], flags: (1 << 6) }); return interaction.editReply({ embeds: [new EmbedBuilder().setColor(client.config.Colors.Green).setDescription(`Successfully set **disableBaseDamage** to ${preference}.\nRestart the DayZ server to apply these changes.`)], flags: (1 << 6) }); - + } else if (args[0].name == 'disable-container-damage') { const preference = args[0].options[0].value; await interaction.deferReply({ flags: (1 << 6) }); @@ -301,16 +301,16 @@ module.exports = { if (disableContainerDamageFailed) return interaction.editReply({ embeds: [new EmbedBuilder().setColor(client.config.Colors.Red).setDescription('Failed to set **disableContainerDamage**. This can result from a variety of reasons:\nNitrado servers may be experiencing issues\nThe DayZ.R Bot may be experiencing issues\nYour Nitrado credentials were entered incorrectly')], flags: (1 << 6) }); return interaction.editReply({ embeds: [new EmbedBuilder().setColor(client.config.Colors.Green).setDescription(`Successfully set **disableContainerDamage** to ${preference}.\nRestart the DayZ server to apply these changes.`)], flags: (1 << 6) }); - + } } }, Interactions: { - + NitradoCredentials: { run: async(client, interaction, GuildDB) => { - if (!interaction.customId.endsWith(interaction.member.user.id)) + if (!interaction.customId.endsWith(interaction.member.user.id)) return interaction.reply({ content: 'This interaction is not for you', flags: (1 << 6) }); const Nitrado = { @@ -344,21 +344,21 @@ module.exports = { const NitradoCredentials = new ModalBuilder() .setTitle('Connect your Nitrado Server') .setCustomId(`NitradoCredentials-${interaction.member.user.id}`); - + const ServerID = new ActionRowBuilder().addComponents(new TextInputBuilder() .setCustomId('ServerIDInput') .setLabel('Your Nitrado Server ID') .setStyle(TextInputStyle.Short) .setRequired(true) ); - + const UserID = new ActionRowBuilder().addComponents(new TextInputBuilder() .setCustomId('UserIDInput') .setLabel('Your Nitrado User ID') .setStyle(TextInputStyle.Short) .setRequired(true) ); - + const Auth = new ActionRowBuilder().addComponents(new TextInputBuilder() .setCustomId('AuthInput') .setLabel('Your Nitrado Authentication Token') @@ -366,9 +366,9 @@ module.exports = { .setStyle(TextInputStyle.Short) .setRequired(true) ); - + NitradoCredentials.addComponents(ServerID, UserID, Auth); - + // TODO: Figure out how to remove the prompt buttons and the embed. return interaction.showModal(NitradoCredentials); } else { diff --git a/commands/weapon-stats.js b/commands/weapon-stats.js index 90bfc06..693be4d 100644 --- a/commands/weapon-stats.js +++ b/commands/weapon-stats.js @@ -61,7 +61,7 @@ module.exports = { return interaction.send({ embeds: [warnNitradoNotInitialized], flags: (1 << 6) }); } - + let discord = args[1] && args[1].name == 'discord' ? args[1].value : undefined; let gamertag = args[1] && args[1].name == 'gamertag' ? args[1].value : undefined; let self = !discord && !gamertag; // searching for self if both discord and gamertag are undefined @@ -71,13 +71,13 @@ module.exports = { // Searching by Discord if (discord) query = await client.dbo.collection("players").findOne({"discordID": discord}); - + // Searching by Gamertag if (gamertag) query = await client.dbo.collection("players").findOne({"gamertag": gamertag}); - + // Searching for self if (self) query = await client.dbo.collection("players").findOne({"discordID": interaction.member.user.id}); - + if (!client.exists(query)) return interaction.send({ embeds: [new EmbedBuilder().setColor(client.config.Colors.Yellow).setDescription(`**Not Found** Unable to find any records with the gamertag or user provided.`)] }); let weaponSelect = new StringSelectMenuBuilder() @@ -103,7 +103,7 @@ module.exports = { run: async(client, interaction, GuildDB) => { if (!interaction.customId.endsWith(interaction.member.user.id)) return interaction.reply({ content: 'This interaction is not for you', flags: (1 << 6) }); - + const weapon = interaction.values[0].split("_")[1]; const weaponClass = interaction.values[0].split("_")[0]; const playerID = interaction.customId.split('-')[1]; @@ -163,12 +163,12 @@ module.exports = { }, }, }; - + const encodedChart = encodeURIComponent(JSON.stringify(chart)); const chartURL = `https://quickchart.io/chart?bkg=${encodeURIComponent("#ded8d7")}&c=${encodedChart}`; - + stats.setImage(chartURL); - + return interaction.update({ components: [], embeds: [stats] }); } } diff --git a/config/config.js b/config/config.js index 8d936a4..4063f0e 100644 --- a/config/config.js +++ b/config/config.js @@ -18,7 +18,7 @@ const PresenceStatus = { }; module.exports = { - Dev: process.env.Dev || "DEV.", + Dev: process.env.Dev || "DEV.", Version: package.version, // (major).(minor).(patch) Admins: ["362791661274660874", "329371697570381824"], // Admins of the bot SupportServer: "https://discord.gg/KVFJCvvFtK", // Support Server Link diff --git a/database/destinations.js b/database/destinations.js index 0e09527..d018bca 100644 --- a/database/destinations.js +++ b/database/destinations.js @@ -32,286 +32,286 @@ const destinations = { coord: [1481.47, 11933.38], }, { name: 'Novaya Petrovka', - coord: [3437.31, 13010.46], + coord: [3437.31, 13010.46], }, { name: 'Zaprundoe', - coord: [5171.52, 12753.83], + coord: [5171.52, 12753.83], }, { name: 'Ratnoe', - coord: [6174.72, 12722.72], + coord: [6174.72, 12722.72], }, { name: 'Severograd', - coord: [7986.69, 12699.39], + coord: [7986.69, 12699.39], }, { name: 'Svergino', - coord: [9464.27, 13718.14], + coord: [9464.27, 13718.14], }, { name: 'West Novodmitrovsk', - coord: [10988.51, 14344.17], + coord: [10988.51, 14344.17], }, { name: 'East Novodmitrovsk', - coord: [12143.35, 14336.39], + coord: [12143.35, 14336.39], }, { name: 'North Novodmitrovsk', - coord: [11544.55, 14764.11], + coord: [11544.55, 14764.11], }, { name: 'Cernaya Polyana', - coord: [12112.25, 13760.91], + coord: [12112.25, 13760.91], }, { name: 'Turovo', - coord: [13585.94, 14060.32], + coord: [13585.94, 14060.32], }, { name: 'Karmanovka', - coord: [12679.95, 14678.56], + coord: [12679.95, 14678.56], }, { name: 'Dobroe', - coord: [12956.02, 15051.85], + coord: [12956.02, 15051.85], }, { name: 'Belaya Polyana', - coord: [14161.41, 14942.97], + coord: [14161.41, 14942.97], }, { name: 'Svetlojarsk', - coord: [14001.99, 13251.54], + coord: [14001.99, 13251.54], }, { name: 'Olsha', - coord: [13348.75, 12897.70], + coord: [13348.75, 12897.70], }, { name: 'Black Lake', - coord: [13438.18, 12127.80], + coord: [13438.18, 12127.80], }, { name: 'Krasno Airfield', - coord: [12018.93, 12586.63], + coord: [12018.93, 12586.63], }, { name: 'Krasnostav', - coord: [11163.49, 12248.34], + coord: [11163.49, 12248.34], }, { name: 'Rify', - coord: [13811.46, 11210.15], + coord: [13811.46, 11210.15], }, { name: 'Khelmn', - coord: [12287.22, 10840.75], + coord: [12287.22, 10840.75], }, { name: 'North Berezino', - coord: [12905.47, 10059.19], + coord: [12905.47, 10059.19], }, { name: 'Central Berezino', - coord: [12423.31, 9600.36], + coord: [12423.31, 9600.36], }, { name: 'South Berezino', - coord: [11968.38, 9079.32], + coord: [11968.38, 9079.32], }, { name: 'Dubrovka', - coord: [10362.48, 9837.55], + coord: [10362.48, 9837.55], }, { name: 'Vyshnaya Dubrovka', - coord: [9891.99, 10432.47], + coord: [9891.99, 10432.47], }, { name: 'North Solnichniy', coord: [13123.22, 7100.15] }, { name: 'Solnichniy', - coord: [13418.74, 6248.60], + coord: [13418.74, 6248.60], }, { name: 'Orlovets', - coord: [12201.68, 7275.12], + coord: [12201.68, 7275.12], }, { name: 'Polana', - coord: [10743.54, 8134.45], + coord: [10743.54, 8134.45], }, { name: 'Gorka', - coord: [9487.60, 8811.03], + coord: [9487.60, 8811.03], }, { name: 'Radio Zenit', - coord: [8128.62, 9230.97], + coord: [8128.62, 9230.97], }, { name: 'Dolina', - coord: [11276.25, 6594.66], + coord: [11276.25, 6594.66], }, { name: 'Devil\'s Castle', - coord: [6890.18, 11439.56], + coord: [6890.18, 11439.56], }, { name: 'Zolotar Castle (Black Mountain)', - coord: [10189.45, 12038.37], + coord: [10189.45, 12038.37], }, { name: 'Kamensk', - coord: [6684.09, 14410.27], + coord: [6684.09, 14410.27], }, { name: 'MB Kamensk', - coord: [7862.27, 14698.01], + coord: [7862.27, 14698.01], }, { name: 'Quarry', - coord: [8614.66, 13333.19], + coord: [8614.66, 13333.19], }, { name: 'Nagornoe', - coord: [9262.08, 14620.24], + coord: [9262.08, 14620.24], }, { name: 'Stary Yar', - coord: [4965.44, 15028.52], + coord: [4965.44, 15028.52], }, { name: 'Tisy', - coord: [3425.65, 14783.55], + coord: [3425.65, 14783.55], }, { name: 'MB Tisy', - coord: [1543.68, 14052.54], + coord: [1543.68, 14052.54], }, { name: 'Topolniki', - coord: [2834.62, 12388.32], + coord: [2834.62, 12388.32], }, { name: 'North NWAF', - coord: [4024.45, 11738.96], + coord: [4024.45, 11738.96], }, { name: 'Central NWAF', - coord: [4249.98, 10766.87], + coord: [4249.98, 10766.87], }, { name: 'South NWAF', - coord: [4864.34, 9588.70], + coord: [4864.34, 9588.70], }, { name: 'Grishino', - coord: [5976.41, 10300.27], + coord: [5976.41, 10300.27], }, { name: 'Kabanino', - coord: [5284.28, 8604.94], + coord: [5284.28, 8604.94], }, { name: 'Stary Sobor', - coord: [6058.07, 7792.28], + coord: [6058.07, 7792.28], }, { name: 'Novy Sobor', - coord: [7088.48, 7648.41], + coord: [7088.48, 7648.41], }, { name: 'MB VMC', - coord: [4483.28, 8286.10], + coord: [4483.28, 8286.10], }, { name: 'Vybor', - coord: [3814.48, 8904.35], + coord: [3814.48, 8904.35], }, { name: 'Pustoshka', - coord: [3060.14, 7905.04], + coord: [3060.14, 7905.04], }, { name: 'Lopatino', - coord: [2725.74, 10016.42], + coord: [2725.74, 10016.42], }, { name: 'Vavilovo', - coord: [2228.03, 11039.06], + coord: [2228.03, 11039.06], }, { name: 'Kalinka', - coord: [3301.22, 11249.03], + coord: [3301.22, 11249.03], }, { name: 'Biathlon Arena', - coord: [493.82, 11093.50], + coord: [493.82, 11093.50], }, { name: 'Krona Castle', - coord: [1395.92, 9246.52], + coord: [1395.92, 9246.52], }, { name: 'Myshkino', - coord: [2010.28, 7317.90], + coord: [2010.28, 7317.90], }, { name: 'Polesovo', - coord: [5929.75, 13523.72], + coord: [5929.75, 13523.72], }, { name: 'Kalinovka', - coord: [7516.20, 13457.62], + coord: [7516.20, 13457.62], }, { name: 'Skalisty Island', - coord: [13620.93, 3040.70], + coord: [13620.93, 3040.70], }, { name: 'Kamyshovo', - coord: [12061.70, 3526.74], + coord: [12061.70, 3526.74], }, { name: 'Elektrozavodsk', - coord: [10273.05, 2010.28], + coord: [10273.05, 2010.28], }, { name: 'Cherno. Prigorodki', - coord: [7733.95, 3182.62], + coord: [7733.95, 3182.62], }, { name: 'Chernogorsk', - coord: [6573.28, 2544.93], + coord: [6573.28, 2544.93], }, { name: 'Cherno. Dubovo', - coord: [6672.43, 3616.18], + coord: [6672.43, 3616.18], }, { name: 'Cherno. Vysotovo', - coord: [5686.73, 2552.71], + coord: [5686.73, 2552.71], }, { name: 'Cherno. Novoselki', - coord: [6139.72, 3239.01], + coord: [6139.72, 3239.01], }, { name: 'Balota Airfield', - coord: [5054.87, 2344.68], + coord: [5054.87, 2344.68], }, { name: 'Balota', - coord: [4463.84, 2441.89], + coord: [4463.84, 2441.89], }, { name: 'Komarovo', - coord: [3670.61, 2457.44], + coord: [3670.61, 2457.44], }, { name: 'Prison Island', - coord: [2702.41, 1296.77], + coord: [2702.41, 1296.77], }, { name: 'Kamenka', - coord: [1905.30, 2231.92], + coord: [1905.30, 2231.92], }, { name: 'MB Pavlovo', - coord: [2130.82, 3363.43], + coord: [2130.82, 3363.43], }, { name: 'Pavlovo', - coord: [1675.88, 3845.59], + coord: [1675.88, 3845.59], }, { name: 'Bor', - coord: [3324.55, 3985.57], + coord: [3324.55, 3985.57], }, { name: 'Nadezhdino', - coord: [5867.54, 4790.46], + coord: [5867.54, 4790.46], }, { name: 'Mogilevka', - coord: [7570.64, 5140.41], + coord: [7570.64, 5140.41], }, { name: 'Pusta', - coord: [9192.09, 3861.14], + coord: [9192.09, 3861.14], }, { name: 'Staroye', - coord: [10136.96, 5443.71], + coord: [10136.96, 5443.71], }, { name: 'MSTA', - coord: [11334.57, 5486.48], + coord: [11334.57, 5486.48], }, { name: 'Tulga', - coord: [12753.83, 4405.51], + coord: [12753.83, 4405.51], }, { name: 'Guglovo', - coord: [8437.74, 6680.21], + coord: [8437.74, 6680.21], }, { name: 'Vyshnoye', - coord: [6586.88, 6054.18], + coord: [6586.88, 6054.18], }, { name: 'Rogovo', - coord: [4763.24, 6765.75], + coord: [4763.24, 6765.75], }, { name: 'Pulkovo', - coord: [4969.33, 5614.79], + coord: [4969.33, 5614.79], }, { name: 'Green Mountain', - coord: [3707.55, 6003.63], + coord: [3707.55, 6003.63], }, { name: 'Zelenogorsk', - coord: [2581.87, 5190.96], + coord: [2581.87, 5190.96], }, { name: 'Sosnovka', - coord: [2527.43, 6369.14], + coord: [2527.43, 6369.14], }, { name: 'Plotina Tishina Damn', - coord: [1193.73, 6363.30], + coord: [1193.73, 6363.30], }, { name: 'Zvir', - coord: [571.59, 5294.00], + coord: [571.59, 5294.00], }, { name: 'Shakhovka', - coord: [9658.69, 6555.78], + coord: [9658.69, 6555.78], }, { name: 'Black Forrest', - coord: [9021.00, 7792.28], + coord: [9021.00, 7792.28], }, { name: 'Nizhneye', - coord: [12971.57, 8142.23], + coord: [12971.57, 8142.23], }, { name: 'Rog Castle', coord: [11249.03, 4281.09], @@ -681,4 +681,4 @@ const destinations = { coord: [11165.63, 7910.63], }, ], -} \ No newline at end of file +} diff --git a/database/player.js b/database/player.js index da6c2dd..cded849 100644 --- a/database/player.js +++ b/database/player.js @@ -57,7 +57,7 @@ module.exports = { longestKill: 0, deathStreak: 0, worstDeathStreak: 0, - + // In depth PVP Stats shotsLanded: 0, timesShot: 0, @@ -75,7 +75,7 @@ module.exports = { highestCombatRating: 800, lowestCombatRating: 800, combatRatingHistory: [800], - + // General Session Data lastConnectionDate: null, lastDisconnectionDate: null, @@ -87,13 +87,13 @@ module.exports = { lastPos: [], time: null, lastTime: null, - + // Session Stats totalSessionTime: 0, lastSessionTime: 0, longestSessionTime: 0, connections: 0, - + // Other bounties: [], bountiesLength: 0, diff --git a/database/weapons.js b/database/weapons.js index 36b0221..d074ec5 100644 --- a/database/weapons.js +++ b/database/weapons.js @@ -15,7 +15,7 @@ module.exports = { "Signal Pistol": "https://static.wikia.nocookie.net/dayz_gamepedia/images/a/a7/Flaregun.png/revision/latest/scale-to-width-down/107?cb=20210501150913", }, shotguns: { - "BK-12": "https://static.wikia.nocookie.net/dayz_gamepedia/images/c/cb/Izh18Shotgun.png/revision/latest/scale-to-width-down/256?cb=20220922184507", + "BK-12": "https://static.wikia.nocookie.net/dayz_gamepedia/images/c/cb/Izh18Shotgun.png/revision/latest/scale-to-width-down/256?cb=20220922184507", "BK-133": "https://static.wikia.nocookie.net/dayz_gamepedia/images/5/5c/MP-133-Shotgun.png/revision/latest/scale-to-width-down/256?cb=20210210190104", "BK-43": "https://static.wikia.nocookie.net/dayz_gamepedia/images/c/c7/Izh43Shotgun.png/revision/latest/scale-to-width-down/256?cb=20210210185835", "Vaiga": "https://static.wikia.nocookie.net/dayz_gamepedia/images/c/c8/Vaiga.png/revision/latest/scale-to-width-down/256?cb=20220220185225", @@ -65,7 +65,7 @@ module.exports = { semiAutomaticRifles: { "DMR": "https://static.wikia.nocookie.net/dayz_gamepedia/images/b/b4/M14.png/revision/latest/scale-to-width-down/350?cb=20231005142636", "SK 59/66": "https://static.wikia.nocookie.net/dayz_gamepedia/images/f/fe/SKS.png/revision/latest/scale-to-width-down/256?cb=20220517154633", - "Sporter 22": "https://static.wikia.nocookie.net/dayz_gamepedia/images/5/5b/Sporter_22_Wood.png/revision/latest/scale-to-width-down/256?cb=20220518204154", + "Sporter 22": "https://static.wikia.nocookie.net/dayz_gamepedia/images/5/5b/Sporter_22_Wood.png/revision/latest/scale-to-width-down/256?cb=20220518204154", }, other: { "Crossbow": "https://static.wikia.nocookie.net/dayz_gamepedia/images/7/79/Crossbow.png/revision/latest/scale-to-width-down/212?cb=20180121164101", diff --git a/events/guildCreate.js b/events/guildCreate.js index ee141d1..80178b8 100644 --- a/events/guildCreate.js +++ b/events/guildCreate.js @@ -1,3 +1,3 @@ module.exports = (client, guild) => { require("../util/RegisterSlashCommands").RegisterGuildCommands(client, guild.id); -}; \ No newline at end of file +}; diff --git a/events/interactionCreate.js b/events/interactionCreate.js index 621aa14..541549c 100644 --- a/events/interactionCreate.js +++ b/events/interactionCreate.js @@ -8,7 +8,7 @@ module.exports = async (client, interaction) => { This file routes any menu, modal & button interactions from any command */ - + let GuildDB = await GetGuild(client, interaction.guildId); const interactionName = interaction.customId.split("-")[0]; let interactionHandler = client.interactionHandlers.get(interactionName); @@ -18,4 +18,4 @@ module.exports = async (client, interaction) => { } catch (err) { client.sendInternalError(interaction, err); } -} \ No newline at end of file +} diff --git a/util/AdminLogsHandler.js b/util/AdminLogsHandler.js index b9142d9..b7130e4 100644 --- a/util/AdminLogsHandler.js +++ b/util/AdminLogsHandler.js @@ -8,7 +8,7 @@ module.exports = { if (!client.exists(guild.connectionLogsChannel)) return; const channel = client.GetChannel(guild.connectionLogsChannel); if (!channel) return; - + let newDt = await client.getDateEST(data.time); let unixTime = Math.floor(newDt.getTime() / 1000); @@ -48,7 +48,7 @@ module.exports = { // If lastHitBy (attacker) died after shooting this player // then it does not count as combat logging, (the combat ended due to death) let attacker = await client.dbo.collection("players").findOne({"gamertag": data.lastHitBy}); - if (attacker.lastDeathDate > data.lastDamageDate) return; + if (attacker.lastDeathDate > data.lastDamageDate) return; let unixTime = Math.floor(newDt.getTime() / 1000); const destination = nearest(data.pos, guild.Nitrado.Mission); @@ -59,7 +59,7 @@ module.exports = { const NAME = "DayZ.R Admin Logs"; const webhook = await GetWebhook(client, NAME, guild.connectionLogsChannel); - + let content = { embeds: [combatLog] }; if (client.exists(guild.adminRole)) content.content = `<@&${guild.adminRole}>`; WebhookSend(client, webhook, content); diff --git a/util/AlarmsHandler.js b/util/AlarmsHandler.js index 6d704c4..2c16cb7 100644 --- a/util/AlarmsHandler.js +++ b/util/AlarmsHandler.js @@ -96,7 +96,7 @@ module.exports = { .setDescription(`**Zone Ping - **\n**${data.player}** was located within **${distance} meters** of the Zone **${alarm.name}**`) .addFields({ name: '**Location**', value: `**[${data.pos[0]}, ${data.pos[1]}](https://www.izurvive.com/chernarusplussatmap/#location=${data.pos[0]};${data.pos[1]})**`, inline: false }) ); - + return; } } @@ -116,7 +116,7 @@ module.exports = { let uavEmbed = new EmbedBuilder() .setColor(client.config.Colors.Default) .setDescription(`**UAV Detection - **\n**${data.player}** was spotted in the UAV zone at **[${data.pos[0]}, ${data.pos[1]}](https://www.izurvive.com/chernarusplussatmap/#location=${data.pos[0]};${data.pos[1]})\n${destination}**`) - + client.users.fetch(uav.owner, false).then((user) => { user.send({ embeds: [uavEmbed] }); }); @@ -133,9 +133,9 @@ module.exports = { let now = new Date(); let diff = Math.round((now.getTime() - uav.creationDate.getTime()) / 1000 / 60); // diff minutes - + if (diff <= 30) continue; - + uavs.splice(i, 1); update = true; @@ -154,9 +154,9 @@ module.exports = { }, KillInAlarm: async (client, guildId, data) => { - + let guild = await GetGuild(client, guildId); - + for (let i = 0; i < guild.alarms.length; i++) { let alarm = guild.alarms[i]; if (alarm.disabled || !alarm.rules.includes('ban_on_kill')) continue; // ignore if alarm is disabled or not ban on kill; @@ -176,10 +176,10 @@ module.exports = { .setColor(client.config.Colors.Default) .setDescription(`**Zone Ping - **\n**${data.killer}** was located within **${distance} meters** of the Zone **${alarm.name}** __and has been banned for killing **${data.victim}**.__`) .addFields({ name: '**Location**', value: `**[${data.killerPOS[0]}, ${data.killerPOS[1]}](https://www.izurvive.com/chernarusplussatmap/#location=${data.killerPOS[0]};${data.killerPOS[1]})**`, inline: false }) - + const NAME = "DayZ.R Zone Alert"; const webhook = await GetWebhook(client, NAME, alarm.channel); - + let content = { content: `<@&${alarm.role}>`, embeds: [alarmEmbed] }; WebhookSend(client, webhook, content); @@ -224,10 +224,10 @@ module.exports = { .setColor(client.config.Colors.Default) .setDescription(`**Zone Ping - **\n**${info.player}** was located within **${distance} meters** of the Zone **${alarm.name}** __and has been banned for **placing a fireplace**.__`) .addFields({ name: '**Location**', value: `**[${info.playerPOS[0]}, ${info.playerPOS[1]}](https://www.izurvive.com/chernarusplussatmap/#location=${info.playerPOS[0]};${info.playerPOS[1]})**`, inline: false }) - + const NAME = "DayZ.R Zone Alert"; const webhook = await GetWebhook(client, NAME, alarm.channel); - + let content = { content: `<@&${alarm.role}>`, embeds: [alarmEmbed] }; WebhookSend(client, webhook, content); diff --git a/util/CommandOptionTypes.js b/util/CommandOptionTypes.js index d74fec1..49d604a 100644 --- a/util/CommandOptionTypes.js +++ b/util/CommandOptionTypes.js @@ -12,4 +12,4 @@ module.exports = { Float: 10, // AKA Number in Discord's Documentation Attachment: 11, } -}; \ No newline at end of file +}; diff --git a/util/Cryptic.js b/util/Cryptic.js index 0f32e46..e742e52 100644 --- a/util/Cryptic.js +++ b/util/Cryptic.js @@ -16,4 +16,4 @@ module.exports = { decipher.final('utf8') ) // Decrypts data and converts to utf8 } -} \ No newline at end of file +} diff --git a/util/Logger.js b/util/Logger.js index c9420bb..06a76ac 100644 --- a/util/Logger.js +++ b/util/Logger.js @@ -35,4 +35,4 @@ class Logger { } } -module.exports = Logger; \ No newline at end of file +module.exports = Logger; diff --git a/util/RegisterSlashCommands.js b/util/RegisterSlashCommands.js index a4c0cc0..993fb1e 100644 --- a/util/RegisterSlashCommands.js +++ b/util/RegisterSlashCommands.js @@ -8,7 +8,7 @@ const { REST } = require('@discordjs/rest'); * @param {require("../structures/DayzRBot")} client */ module.exports = { - // Register guild commands + // Register guild commands RegisterGuildCommands: async (client, guild) => { const commands = []; const commandFiles = fs.readdirSync(path.join(__dirname, "..", "commands")).filter(file => file.endsWith('.js')); @@ -50,7 +50,7 @@ module.exports = { if (command.global) commands.push(command); } - const rest = new REST({ version: '10' }).setToken(client.config.Token); + const rest = new REST({ version: '10' }).setToken(client.config.Token); try { client.log('[global] Started refreshing global (/) commands.'); @@ -65,4 +65,4 @@ module.exports = { client.error(error); } } -}; \ No newline at end of file +}; diff --git a/util/Vector.js b/util/Vector.js index da6f0a0..6c14349 100644 --- a/util/Vector.js +++ b/util/Vector.js @@ -6,7 +6,7 @@ module.exports = { let theta = (thetat < 0) ? (360 + thetat) : thetat; let compass = ["S", "SW", "W", "NW", "N", "NE", "E", "SE", "S"]; let dir = compass[Math.round(theta / 45)]; - + return {distance, theta, dir} - } -} \ No newline at end of file + } +}