2020-04-04 04:23:29 +00:00
|
|
|
module.exports = function statisticsUpdate(client, guild, radio) {
|
|
|
|
|
|
|
|
client.datastore.checkEntry(guild.id);
|
|
|
|
|
|
|
|
radio.currentGuild = client.datastore.getEntry(guild.id);
|
|
|
|
|
|
|
|
if(!radio.currentGuild.statistics[radio.station.name]){
|
|
|
|
radio.currentGuild.statistics[radio.station.name] = {};
|
|
|
|
radio.currentGuild.statistics[radio.station.name].time = 0;
|
|
|
|
radio.currentGuild.statistics[radio.station.name].used = 0;
|
|
|
|
client.datastore.updateEntry(guild, radio.currentGuild);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!radio.connection.dispatcher){
|
|
|
|
let date = new Date();
|
|
|
|
radio.currentTime = date.getTime();
|
|
|
|
radio.playTime = parseInt(radio.currentTime)-parseInt(radio.startTime);
|
|
|
|
radio.currentGuild.statistics[radio.station.name].time = parseInt(radio.currentGuild.statistics[radio.station.name].time)+parseInt(radio.playTime);
|
|
|
|
} else {
|
|
|
|
radio.currentGuild.statistics[radio.station.name].time = parseInt(radio.currentGuild.statistics[radio.station.name].time)+parseInt(radio.connection.dispatcher.streamTime.toFixed(0));
|
|
|
|
}
|
|
|
|
|
|
|
|
radio.currentGuild.statistics[radio.station.name].used = parseInt(radio.currentGuild.statistics[radio.station.name].used)+1;
|
|
|
|
client.datastore.updateEntry(guild, radio.currentGuild);
|
2021-01-07 00:58:53 +00:00
|
|
|
client.datastore.calculateGlobal(client);
|
2020-04-02 05:40:05 +00:00
|
|
|
}
|