From cbdbd18051e2667807249c777ed6dbb00748a63f Mon Sep 17 00:00:00 2001 From: Braeden Sowinski Date: Mon, 4 Sep 2023 10:44:01 -0700 Subject: [PATCH] update/configure show killfeed coords --- commands/config.js | 28 +++++++++++++++++++++++++++- package.json | 2 +- structures/DayzRBot.js | 1 + util/KillfeedHandler.js | 13 +++++++++---- 4 files changed, 38 insertions(+), 6 deletions(-) diff --git a/commands/config.js b/commands/config.js index f0d168c..127e8a1 100644 --- a/commands/config.js +++ b/commands/config.js @@ -299,10 +299,23 @@ module.exports = { options: [{ name: "hours", description: "Number of hours till income can be collected", - value: 168.00, + value: 168.00, // 1 week type: 10, required: true, }] + }, + { + name: "show_killfeed_coords", + description: "Show the coordinates of the killer or victim in the killfeed channel.", + value: "show_killfeed_coords", + type: 1, + options: [{ + name: "configuration", + description: "True or False", + value: false, + type: 5, + required: true, + }] } ], SlashCommand: { @@ -507,6 +520,19 @@ module.exports = { return interaction.send({ embeds: [successSetKillfeedChannelEmbed] }); + case 'show_killfeed_coords': + const showKillfeedCoordsConfiguration = args[0].options[0].value; + + client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$set: {"server.showKillfeedCoords": showKillfeedCoordsConfiguration}}, function(err, res) { + 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] }); + case 'admin_logs_channel': const adminLogsChannel = args[0].options[0].value; diff --git a/package.json b/package.json index f852794..807c61e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dayzr-bot", - "version": "9.5.3", + "version": "9.6.0", "description": "A General Purpose Discord Bot for DayZ Nitrado Servers.", "main": "index.js", "nodemonConfig": { diff --git a/structures/DayzRBot.js b/structures/DayzRBot.js index 7b393fb..fe3b40e 100644 --- a/structures/DayzRBot.js +++ b/structures/DayzRBot.js @@ -348,6 +348,7 @@ class DayzRBot extends Client { serverID: GuildId, allowedChannels: [], killfeedChannel: "", + showKillfeedCoords: false, connectionLogsChannel: "", activePlayersChannel: "", welcomeChannel: "", diff --git a/util/KillfeedHandler.js b/util/KillfeedHandler.js index 20e6eaa..fa5f84f 100644 --- a/util/KillfeedHandler.js +++ b/util/KillfeedHandler.js @@ -75,12 +75,15 @@ module.exports = { let newDt = await client.getDateEST(info.time); let unixTime = Math.floor(newDt.getTime()/1000); + const showCoords = client.exists(guild.showKillfeedCoords) ? guild.showKillfeedCoords : false; // default to false if no record of configuration. + if (killedBy == Templates.LandMine || killedBy == Templates.Explosion || killedBy == Templates.Vehicle) { - let cod = killedBy == Templates.LandMine ? `Land Mine Trap` : info.causeOfDeath; - + const cod = killedBy == Templates.LandMine ? `Land Mine Trap` : info.causeOfDeath; + const coord = showCoords ? `\nLocation [${info.victimPOS[0]}, ${info.victimPOS[1]}](https://www.izurvive.com/chernarusplussatmap/#location=${info.victimPOS[0]};${info.victimPOS[1]})**` : ''; + const killEvent = new EmbedBuilder() .setColor(client.config.Colors.Default) - .setDescription(`**Death Event** - \n**${info.victim}** killed by a **${cod}.\nLocation [${info.victimPOS[0]}, ${info.victimPOS[1]}](https://www.izurvive.com/chernarusplussatmap/#location=${info.victimPOS[0]};${info.victimPOS[1]})**`); + .setDescription(`**Death Event** - \n**${info.victim}** killed by a **${cod}.${coord}`); if (client.exists(channel)) await channel.send({ embeds: [killEvent] }); return stats; @@ -165,9 +168,11 @@ module.exports = { if (victimStatIndex == -1) stats.push(victimStat); else stats[victimStatIndex] = victimStat; + const coord = showCoord ? `\nLocation [${info.killerPOS[0]}, ${info.killerPOS[1]}](https://www.izurvive.com/chernarusplussatmap/#location=${info.killerPOS[0]};${info.killerPOS[1]})**` : ''; + const killEvent = new EmbedBuilder() .setColor(client.config.Colors.Default) - .setDescription(`**Kill Event** - \n**${info.killer}** killed **${info.victim}**\n> **__Kill Data__**\n> **Weapon:** \` ${info.weapon} \`\n> **Distance:** \` ${info.distance} \`\n> **Body Part:** \` ${info.bodyPart != undefined ? info.bodyPart.split('(')[0] : 'N/A'} \`\n> **Damage:** \` ${info.damage != undefined ? info.damage : 'N/A'} \`\n **Killer\n${killerStat.KDR.toFixed(2)} K/D - ${killerStat.kills} Kill${(killerStat.kills == 0 || killerStat.kills > 1) ? 's':''} - Killstreak: ${killerStat.killStreak}\nVictim\n${victimStat.KDR.toFixed(2)} K/D - ${victimStat.deaths} Deaths - Deathstreak: ${victimStat.deathStreak}\nLocation [${info.killerPOS[0]}, ${info.killerPOS[1]}](https://www.izurvive.com/chernarusplussatmap/#location=${info.killerPOS[0]};${info.killerPOS[1]})**`); + .setDescription(`**Kill Event** - \n**${info.killer}** killed **${info.victim}**\n> **__Kill Data__**\n> **Weapon:** \` ${info.weapon} \`\n> **Distance:** \` ${info.distance} \`\n> **Body Part:** \` ${info.bodyPart != undefined ? info.bodyPart.split('(')[0] : 'N/A'} \`\n> **Damage:** \` ${info.damage != undefined ? info.damage : 'N/A'} \`\n **Killer\n${killerStat.KDR.toFixed(2)} K/D - ${killerStat.kills} Kill${(killerStat.kills == 0 || killerStat.kills > 1) ? 's':''} - Killstreak: ${killerStat.killStreak}\nVictim\n${victimStat.KDR.toFixed(2)} K/D - ${victimStat.deaths} Deaths - Deathstreak: ${victimStat.deathStreak}${coord}`); if (client.exists(channel)) await channel.send({ embeds: [killEvent] }); if (client.exists(receivedBounty) && client.exists(channel)) await channel.send({ content: `<@${killerStat.discordID}>`, embeds: [receivedBounty] });