2020-04-02 07:34:04 +00:00
|
|
|
module.exports = function statisticsUpdate(client, guild, radio) {
|
2020-04-02 05:40:05 +00:00
|
|
|
|
2020-04-02 07:34:04 +00:00
|
|
|
client.datastore.checkEntry(guild.id);
|
2020-04-02 05:40:05 +00:00
|
|
|
|
2020-04-02 07:34:04 +00:00
|
|
|
radio.currentGuild = client.datastore.getEntry(guild.id);
|
2020-04-02 05:40:05 +00:00
|
|
|
|
|
|
|
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;
|
2020-04-02 07:34:04 +00:00
|
|
|
client.datastore.updateEntry(guild, radio.currentGuild);
|
2020-04-02 05:40:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2020-04-02 07:34:04 +00:00
|
|
|
client.datastore.updateEntry(guild, radio.currentGuild);
|
2020-04-02 05:40:05 +00:00
|
|
|
|
|
|
|
}
|