fix timestamp
This commit is contained in:
2 files changed
+14
-13
No files matched your search
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "dayz-armbands",
|
"name": "dayz-armbands",
|
||||||
"version": "5.11.14",
|
"version": "5.11.15",
|
||||||
"description": "A General Purpose Discord Bot for DayZ Servers.",
|
"description": "A General Purpose Discord Bot for DayZ Servers.",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"nodemonConfig": {
|
"nodemonConfig": {
|
||||||
|
|||||||
+13
-12
@@ -96,6 +96,13 @@ class DayzArmbands extends Client {
|
|||||||
const client = this;
|
const client = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getDateEST(time) {
|
||||||
|
let t = new Date(); // Get current date (PST)
|
||||||
|
let e = new Date(t.getTime() + 180*60*1000); // Convert to EST
|
||||||
|
let n = new Date(`${e.toLocaleDateString('default',{month:'long'})} ${e.getDate()}, ${e.getFullYear()} ${time}`) // Apply given time to EST date
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
async downloadFile(file, outputDir) {
|
async downloadFile(file, outputDir) {
|
||||||
const res = await fetch(`https://api.nitrado.net/services/${this.config.Nitrado.ServerID}/gameservers/file_server/download?file=${file}`, {
|
const res = await fetch(`https://api.nitrado.net/services/${this.config.Nitrado.ServerID}/gameservers/file_server/download?file=${file}`, {
|
||||||
headers: {
|
headers: {
|
||||||
@@ -218,8 +225,7 @@ class DayzArmbands extends Client {
|
|||||||
if (victimStatIndex == -1) stats.push(victimStat);
|
if (victimStatIndex == -1) stats.push(victimStat);
|
||||||
else stats[victimStatIndex] = victimStat;
|
else stats[victimStatIndex] = victimStat;
|
||||||
|
|
||||||
let today = new Date();
|
let newDt = await this.getDateEST(info.time);
|
||||||
let newDt = new Date(`${today.toLocaleDateString('default', { month: 'long' })} ${today.getDate()}, ${today.getFullYear()} ${info.time} EST`)
|
|
||||||
let unixTime = Math.floor(newDt.getTime()/1000);
|
let unixTime = Math.floor(newDt.getTime()/1000);
|
||||||
|
|
||||||
const killEvent = new EmbedBuilder()
|
const killEvent = new EmbedBuilder()
|
||||||
@@ -257,8 +263,7 @@ class DayzArmbands extends Client {
|
|||||||
if (distance < alarm.radius) {
|
if (distance < alarm.radius) {
|
||||||
const channel = this.channels.cache.get(alarm.channel);
|
const channel = this.channels.cache.get(alarm.channel);
|
||||||
|
|
||||||
let today = new Date();
|
let newDt = await this.getDateEST(data.time);
|
||||||
let newDt = new Date(`${today.toLocaleDateString('default', { month: 'long' })} ${today.getDate()}, ${today.getFullYear()} ${data.time} EST`);
|
|
||||||
let unixTime = Math.floor(newDt.getTime()/1000);
|
let unixTime = Math.floor(newDt.getTime()/1000);
|
||||||
|
|
||||||
// if (alarm.rules.includes['ban_on_entry']) {
|
// if (alarm.rules.includes['ban_on_entry']) {
|
||||||
@@ -289,8 +294,7 @@ class DayzArmbands extends Client {
|
|||||||
if (!this.exists(guild.connectionLogsChannel)) return;
|
if (!this.exists(guild.connectionLogsChannel)) return;
|
||||||
const channel = this.channels.cache.get(guild.connectionLogsChannel);
|
const channel = this.channels.cache.get(guild.connectionLogsChannel);
|
||||||
|
|
||||||
let today = new Date();
|
let newDt = await this.getDateEST(data.time);
|
||||||
let newDt = new Date(`${today.toLocaleDateString('default', { month: 'long' })} ${today.getDate()}, ${today.getFullYear()} ${data.time} EST`);
|
|
||||||
let unixTime = Math.floor(newDt.getTime()/1000);
|
let unixTime = Math.floor(newDt.getTime()/1000);
|
||||||
|
|
||||||
let connectionLog = new EmbedBuilder()
|
let connectionLog = new EmbedBuilder()
|
||||||
@@ -311,8 +315,7 @@ class DayzArmbands extends Client {
|
|||||||
async detectCombatLog(guildId, data) {
|
async detectCombatLog(guildId, data) {
|
||||||
if (data.lastDamageDate == null) return;
|
if (data.lastDamageDate == null) return;
|
||||||
|
|
||||||
let today = new Date();
|
let newDt = await this.getDateEST(data.time);
|
||||||
let newDt = new Date(`${today.toLocaleDateString('default', { month: 'long' })} ${today.getDate()}, ${today.getFullYear()} ${data.time} EST`);
|
|
||||||
|
|
||||||
let diffMs = (newDt - data.lastDamageDate)
|
let diffMs = (newDt - data.lastDamageDate)
|
||||||
let diffMins = Math.round(((diffMs % 86400000) % 3600000) / 60000); // minutes
|
let diffMins = Math.round(((diffMs % 86400000) % 3600000) / 60000); // minutes
|
||||||
@@ -358,8 +361,7 @@ class DayzArmbands extends Client {
|
|||||||
let playerStatIndex = stats.indexOf(playerStat);
|
let playerStatIndex = stats.indexOf(playerStat);
|
||||||
if (playerStat == undefined) playerStat = this.getDefaultPlayerStats(info.player, info.playerID);
|
if (playerStat == undefined) playerStat = this.getDefaultPlayerStats(info.player, info.playerID);
|
||||||
|
|
||||||
let today = new Date();
|
let newDt = await this.getDateEST(data.time);
|
||||||
let newDt = new Date(`${today.toLocaleDateString('default', { month: 'long' })} ${today.getDate()}, ${today.getFullYear()} ${info.time} EST`);
|
|
||||||
|
|
||||||
playerStat.lastConnectionDate = newDt;
|
playerStat.lastConnectionDate = newDt;
|
||||||
playerStat.connected = true;
|
playerStat.connected = true;
|
||||||
@@ -462,8 +464,7 @@ class DayzArmbands extends Client {
|
|||||||
let playerStatIndex = stats.indexOf(playerStat);
|
let playerStatIndex = stats.indexOf(playerStat);
|
||||||
if (playerStat == undefined) playerStat = this.getDefaultPlayerStats(info.player, info.playerID);
|
if (playerStat == undefined) playerStat = this.getDefaultPlayerStats(info.player, info.playerID);
|
||||||
|
|
||||||
let today = new Date();
|
let newDt = await this.getDateEST(data.time);
|
||||||
let newDt = new Date(`${today.toLocaleDateString('default', { month: 'long' })} ${today.getDate()}, ${today.getFullYear()} ${info.time} EST`);
|
|
||||||
|
|
||||||
playerStat.lastDamageDate = newDt;
|
playerStat.lastDamageDate = newDt;
|
||||||
playerStat.lastHitBy = attackerID;
|
playerStat.lastHitBy = attackerID;
|
||||||
|
|||||||
Reference in new issue
Block a user