2021-09-05 00:17:21 +00:00
|
|
|
|
import Discord from "discord.js";
|
|
|
|
|
|
2021-09-05 19:37:26 +00:00
|
|
|
|
|
2021-06-08 09:01:56 +00:00
|
|
|
|
module.exports = {
|
|
|
|
|
name: 'statistics',
|
2021-08-26 15:00:04 +00:00
|
|
|
|
description: 'Show statistics',
|
2021-06-08 09:01:56 +00:00
|
|
|
|
category: 'info',
|
2021-09-05 00:17:21 +00:00
|
|
|
|
execute(interaction, client) {
|
2021-06-08 09:01:56 +00:00
|
|
|
|
let message = {};
|
|
|
|
|
let stations = client.stations;
|
2021-08-18 22:52:16 +00:00
|
|
|
|
let currentGuild = client.datastore.getEntry(interaction.guild.id);
|
2021-09-05 03:15:54 +00:00
|
|
|
|
let global = client.datastore.getEntry("global");
|
2021-06-08 09:01:56 +00:00
|
|
|
|
let statistics = "";
|
2021-09-09 09:44:50 +00:00
|
|
|
|
|
2021-08-26 15:14:15 +00:00
|
|
|
|
if(!client.stations) {
|
|
|
|
|
message.errorToGetPlaylist = client.messages.errorToGetPlaylist.replace("%client.config.supportGuild%", client.config.supportGuild);
|
2021-09-06 11:42:49 +00:00
|
|
|
|
return interaction.reply({
|
|
|
|
|
content: client.messageEmojis["error"] + message.errorToGetPlaylist,
|
|
|
|
|
ephemeral: true
|
|
|
|
|
});
|
2021-08-26 15:14:15 +00:00
|
|
|
|
}
|
2021-06-08 09:01:56 +00:00
|
|
|
|
|
|
|
|
|
if(!currentGuild || currentGuild && !currentGuild.statistics){
|
2021-09-05 20:11:26 +00:00
|
|
|
|
statistics = "You have not listened any radio stations";
|
2021-06-08 09:01:56 +00:00
|
|
|
|
} else {
|
|
|
|
|
Object.keys(stations).forEach(function(station) {
|
|
|
|
|
if(currentGuild.statistics[stations[station].name] && currentGuild.statistics[stations[station].name].time && parseInt(currentGuild.statistics[stations[station].name].time) > 0 && currentGuild.statistics[stations[station].name].used && parseInt(currentGuild.statistics[stations[station].name].used) > 0){
|
2021-09-05 03:15:54 +00:00
|
|
|
|
statistics += `**${parseInt(station) + 1}. ` + stations[station].name + "** \n";
|
|
|
|
|
if(global && global.statistics[stations[station].name] && global.statistics[stations[station].name].time && parseInt(global.statistics[stations[station].name].time) > 0 && global.statistics[stations[station].name].used && parseInt(global.statistics[stations[station].name].used) > 0){
|
2021-09-05 20:11:26 +00:00
|
|
|
|
statistics += "Guild – Time: " + client.funcs.msToTime(currentGuild.statistics[stations[station].name].time) + " (" + ((currentGuild.statistics[stations[station].name].time / global.statistics[stations[station].name].time) * 100).toFixed(0) + "%" + ")" + " / " + "Used: " + currentGuild.statistics[stations[station].name].used + " (" + ((currentGuild.statistics[stations[station].name].used / global.statistics[stations[station].name].used) * 100).toFixed(0) + "%" + ")" + "\n";
|
2021-09-05 03:15:54 +00:00
|
|
|
|
statistics += "Global – Time: " + client.funcs.msToTime(global.statistics[stations[station].name].time) + " / " + "Used: " + global.statistics[stations[station].name].used + "\n\n";
|
|
|
|
|
} else {
|
|
|
|
|
statistics += "Time: " + client.funcs.msToTime(currentGuild.statistics[stations[station].name].time) + " / " + "Used: " + currentGuild.statistics[stations[station].name].used + "\n\n";
|
|
|
|
|
}
|
2021-06-08 09:01:56 +00:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
2021-09-09 09:44:50 +00:00
|
|
|
|
|
2021-06-08 09:01:56 +00:00
|
|
|
|
const embed = new Discord.MessageEmbed()
|
|
|
|
|
.setTitle(client.messages.statisticsTitle)
|
|
|
|
|
.setThumbnail("https://cdn.discordapp.com/emojis/" + client.messageEmojis["statistics"].replace(/[^0-9]+/g, ''))
|
|
|
|
|
.setColor(client.config.embedColor)
|
|
|
|
|
.setDescription(statistics)
|
2021-09-03 00:46:44 +00:00
|
|
|
|
.setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png')
|
2021-06-08 09:01:56 +00:00
|
|
|
|
.setFooter(client.messages.footerText, "https://cdn.discordapp.com/emojis/" + client.messageEmojis["eximiabots"].replace(/[^0-9]+/g, ''));
|
2021-08-26 19:06:15 +00:00
|
|
|
|
|
|
|
|
|
interaction.reply({
|
|
|
|
|
embeds: [embed],
|
|
|
|
|
ephemeral: true
|
|
|
|
|
});
|
2021-06-08 09:01:56 +00:00
|
|
|
|
}
|
2021-09-09 09:44:50 +00:00
|
|
|
|
};
|