eximiabots-radiox/src/client/commands/statistics.js

39 lines
2.1 KiB
JavaScript
Raw Normal View History

2021-06-08 09:01:56 +00:00
module.exports = {
name: 'statistics',
alias: 'stats',
usage: '',
description: 'Show statistics',
2021-06-08 09:01:56 +00:00
permission: 'none',
category: 'info',
2021-08-18 22:52:16 +00:00
execute(interaction, client, Discord, command) {
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-06-08 09:01:56 +00:00
let statistics = "";
if(!client.stations) {
message.errorToGetPlaylist = client.messages.errorToGetPlaylist.replace("%client.config.supportGuild%", client.config.supportGuild);
return interaction.reply(client.messageEmojis["error"] + message.errorToGetPlaylist);
}
2021-06-08 09:01:56 +00:00
if(!currentGuild || currentGuild && !currentGuild.statistics){
statistics = "You have not listened any radio station";
} 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){
statistics += `**${parseInt(station) + 1}** ` + stations[station].name + " \n";
statistics += "Time: " + client.funcs.msToTime(currentGuild.statistics[stations[station].name].time) + "\n";
2021-06-08 09:01:56 +00:00
statistics += "Used: " + currentGuild.statistics[stations[station].name].used + "\n";
}
});
}
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)
.setFooter(client.messages.footerText, "https://cdn.discordapp.com/emojis/" + client.messageEmojis["eximiabots"].replace(/[^0-9]+/g, ''));
2021-08-18 22:52:16 +00:00
return interaction.reply({ embeds: [embed] });
2021-06-08 09:01:56 +00:00
}
2020-04-02 05:13:51 +00:00
};