update/include general location in location command output
This commit is contained in:
2 files changed
+20
-2
No files matched your search
+19
-1
@@ -1,4 +1,6 @@
|
|||||||
const { EmbedBuilder } = require('discord.js');
|
const { EmbedBuilder } = require('discord.js');
|
||||||
|
const { destinations } = require('../database/destinations');
|
||||||
|
const { calculateVector } = require('../util/Vector');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: "location",
|
name: "location",
|
||||||
@@ -25,9 +27,25 @@ module.exports = {
|
|||||||
let newDt = await client.getDateEST(playerStat.time);
|
let newDt = await client.getDateEST(playerStat.time);
|
||||||
let unixTime = Math.floor(newDt.getTime()/1000);
|
let unixTime = Math.floor(newDt.getTime()/1000);
|
||||||
|
|
||||||
|
let tempDest;
|
||||||
|
let lastDist = 1000000;
|
||||||
|
let destination_dir;
|
||||||
|
if (showCoords) { // Only calculate if showing coords, very tiny minor optimization... probably amounts to nothing.
|
||||||
|
for (let i = 0; i < destinations.length; i++) {
|
||||||
|
let { distance, theta, dir } = calculateVector(info.victimPOS, destinations[i].coord);
|
||||||
|
if (distance < lastDist) {
|
||||||
|
tempDest = destinations[i].name;
|
||||||
|
lastDist = distance;
|
||||||
|
destination_dir = dir;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const destination = lastDist > 500 ? `${destination_dir} of ${tempDest}` : `Near ${tempDest}`;
|
||||||
|
|
||||||
let lastLocation = new EmbedBuilder()
|
let lastLocation = new EmbedBuilder()
|
||||||
.setColor(client.config.Colors.Default)
|
.setColor(client.config.Colors.Default)
|
||||||
.setDescription(`**Location - <t:${unixTime}>**\nYour last location was detected at **[${playerStat.pos[0]}, ${playerStat.pos[1]}](https://www.izurvive.com/chernarusplussatmap/#location=${playerStat.pos[0]};${playerStat.pos[1]})**`)
|
.setDescription(`**Location - <t:${unixTime}>**\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) });
|
return interaction.send({ embeds: [lastLocation], flags: (1 << 6) });
|
||||||
},
|
},
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "dayzr-bot",
|
"name": "dayzr-bot",
|
||||||
"version": "12.5.13",
|
"version": "12.6.0",
|
||||||
"description": "A General Purpose Discord Bot for DayZ Nitrado Servers.",
|
"description": "A General Purpose Discord Bot for DayZ Nitrado Servers.",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"nodemonConfig": {
|
"nodemonConfig": {
|
||||||
|
|||||||
Reference in new issue
Block a user