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

46 lines
1.9 KiB
JavaScript
Raw Normal View History

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',
description: 'Show statistics',
2021-06-08 09:01:56 +00:00
category: 'info',
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
if(!client.stations) {
message.errorToGetPlaylist = client.messages.errorToGetPlaylist.replace("%client.config.supportGuild%", client.config.supportGuild);
return interaction.reply({
content: client.messageEmojis["error"] + message.errorToGetPlaylist,
ephemeral: true
});
}
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 {
2022-04-07 00:24:36 +00:00
statistics = "[Open Dashboard](https://eximiabots.waren.io/radiox/" + interaction.guild.id + "/stats?info=" + Buffer.from(JSON.stringify(currentGuild), 'utf8').toString('base64') + "&globalInfo=" + Buffer.from(JSON.stringify(global), 'utf8').toString('base64') + ")" + "\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)
.setImage('https://waren.io/berriabot-temp-sa7a36a9xm6837br/images/empty-3.png')
.setFooter({
text: client.messages.footerText,
iconURL: "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
};