Можно ли что-то тут сделать правильнее/лучше? Буду благодарен за помощь (я новичок)
const { VK } = require('vk-io');
const vk = new VK({ token: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" });
const acc = require('./acc.json');
const fs = require('fs');
function unixDate(stamp) {
let date = new Date(stamp),
year = date.getFullYear(),
month = (("0" + (date.getMonth() + 1)).slice(-2)),
day = (("0" + (date.getDate())).slice(-2))
return `${day}.${month}.${year}`;
};
function unixTime(stamp) {
let date = new Date(stamp),
hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours(),
mins = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes(),
return `${hour}:${mins}`;
};
function getDate() {
return unixDate(Date.now());
};
function getTime() {
return unixTime(Date.now());
};
vk.updates.use((ctx, next) => {
if (Number(ctx.senderId) <= 0 || ctx.senderId === undefined) return;
if (!acc.users.find(x => x.vk === ctx.senderId)) {
acc.number++;
acc.users.push({
id: acc.number,
vk: ctx.senderId,
nickname: 'Неизвестно',
level: 1,
admin: 0,
balance: 0,
winGame: 0,
lossGame: 0,
dateReg: getDate(),
timeReg: getTime(),
});
};
if (ctx.senderId < 0) return;
return next();
});