eximiabots-radiox/src/client/funcs/statisticsUpdate.js

22 lines
1.0 KiB
JavaScript
Raw Normal View History

2021-06-08 09:01:56 +00:00
module.exports = function statisticsUpdate(client, guild, radio) {
client.datastore.checkEntry(guild.id);
2021-09-02 22:23:35 +00:00
radio.datastore = client.datastore.getEntry(guild.id);
2021-06-08 09:01:56 +00:00
2021-09-02 22:23:35 +00:00
if(!radio.datastore.statistics[radio.station.name]){
radio.datastore.statistics[radio.station.name] = {};
radio.datastore.statistics[radio.station.name].time = 0;
radio.datastore.statistics[radio.station.name].used = 0;
client.datastore.updateEntry(guild, radio.datastore);
2021-06-08 09:01:56 +00:00
}
2021-08-08 17:06:30 +00:00
let date = new Date();
radio.currentTime = date.getTime();
radio.playTime = parseInt(radio.currentTime)-parseInt(radio.startTime);
2021-09-02 22:23:35 +00:00
radio.datastore.statistics[radio.station.name].time = parseInt(radio.datastore.statistics[radio.station.name].time)+parseInt(radio.playTime);
2021-06-08 09:01:56 +00:00
2021-09-02 22:23:35 +00:00
radio.datastore.statistics[radio.station.name].used = parseInt(radio.datastore.statistics[radio.station.name].used)+1;
client.datastore.updateEntry(guild, radio.datastore);
2021-06-08 09:01:56 +00:00
client.datastore.calculateGlobal(client);
2020-04-02 05:40:05 +00:00
}