mirror of
https://github.com/warengroup/eximiabots-radiox.git
synced 2024-11-09 23:00:18 +00:00
Fixed file encoding issue & statistics command when guild has empty statistics
This commit is contained in:
parent
3da41e44cb
commit
20d5d8b3bd
@ -7,24 +7,26 @@ module.exports = {
|
|||||||
category: 'info',
|
category: 'info',
|
||||||
execute(msg, args, client, Discord, command) {
|
execute(msg, args, client, Discord, command) {
|
||||||
let stations = client.stations;
|
let stations = client.stations;
|
||||||
let currentGuildStatistics = client.datastore.getEntry(msg.guild.id).statistics;
|
let currentGuild = client.datastore.getEntry(msg.guild.id);
|
||||||
let statistics;
|
let statistics;
|
||||||
let i = 0;
|
let i = 0;
|
||||||
|
|
||||||
Object.keys(client.stations).forEach(function(station) {
|
if(currentGuild.statistics){
|
||||||
if(currentGuildStatistics[stations[station].name]){
|
Object.keys(client.stations).forEach(function(station) {
|
||||||
if(i > 0){
|
if(currentGuild.statistics[stations[station].name]){
|
||||||
statistics += "**" + station + " " + stations[station].name + "** \n";
|
if(i > 0){
|
||||||
statistics += "Time: " + msToTime(currentGuildStatistics[stations[station].name].time, "hh:mm:ss") + "\n";
|
statistics += "**" + station + " " + stations[station].name + "** \n";
|
||||||
statistics += "Used: " + currentGuildStatistics[stations[station].name].used + "\n";
|
statistics += "Time: " + msToTime(currentGuild.statistics[stations[station].name].time, "hh:mm:ss") + "\n";
|
||||||
} else {
|
statistics += "Used: " + currentGuild.statistics[stations[station].name].used + "\n";
|
||||||
statistics = "**" + station + " " + stations[station].name + "** \n";
|
} else {
|
||||||
statistics += "Time: " + msToTime(currentGuildStatistics[stations[station].name].time, "hh:mm:ss") + "\n";
|
statistics = "**" + station + " " + stations[station].name + "** \n";
|
||||||
statistics += "Used: " + currentGuildStatistics[stations[station].name].used + "\n";
|
statistics += "Time: " + msToTime(currentGuild.statistics[stations[station].name].time, "hh:mm:ss") + "\n";
|
||||||
|
statistics += "Used: " + currentGuild.statistics[stations[station].name].used + "\n";
|
||||||
|
}
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
i++;
|
});
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
if(!statistics){
|
if(!statistics){
|
||||||
statistics = "You have not listened any radio station";
|
statistics = "You have not listened any radio station";
|
||||||
|
@ -76,7 +76,7 @@ module.exports = class {
|
|||||||
saveEntry(file, data) {
|
saveEntry(file, data) {
|
||||||
data = JSON.stringify(data, null, 4);
|
data = JSON.stringify(data, null, 4);
|
||||||
|
|
||||||
fs.writeFile(path.join(path.dirname(__dirname), 'datastore') + "/" + file + ".json", data, function(err) {
|
fs.writeFile(path.join(path.dirname(__dirname), 'datastore') + "/" + file + ".json", data, 'utf8', function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
//console.log(err);
|
//console.log(err);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user