aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinteck <contact@minteck.org>2022-02-13 16:32:59 +0100
committerMinteck <contact@minteck.org>2022-02-13 16:32:59 +0100
commit9284ccc79f186efa34b2f8bd2543cc37c636c0b1 (patch)
tree1fd92fc5c37e577c1e01b3b5ed83e2fa7ed49f1c
parent06ea49feb4000e7e76e5960c310a73c0432ea183 (diff)
downloadponyfind-9284ccc79f186efa34b2f8bd2543cc37c636c0b1.tar.gz
ponyfind-9284ccc79f186efa34b2f8bd2543cc37c636c0b1.tar.bz2
ponyfind-9284ccc79f186efa34b2f8bd2543cc37c636c0b1.zip
Stats for episodes
-rw-r--r--bot.js2
-rw-r--r--commands/episode.js7
2 files changed, 9 insertions, 0 deletions
diff --git a/bot.js b/bot.js
index 2eee3da..33008ef 100644
--- a/bot.js
+++ b/bot.js
@@ -18,6 +18,7 @@ if (!fs.existsSync("./stats/by-day.json")) fs.writeFileSync("./stats/by-day.json
if (!fs.existsSync("./stats/by-hour.json")) fs.writeFileSync("./stats/by-hour.json", '{"0":{},"1":{},"2":{},"3":{},"4":{},"5":{},"6":{},"7":{},"8":{},"9":{},"10":{},"11":{},"12":{},"13":{},"14":{},"15":{},"16":{},"17":{},"18":{},"19":{},"20":{},"21":{},"22":{},"23":{}}');
if (!fs.existsSync("./stats/commands.json")) fs.writeFileSync("./stats/commands.json", "{}");
if (!fs.existsSync("./stats/ponies.json")) fs.writeFileSync("./stats/ponies.json", "{}");
+if (!fs.existsSync("./stats/episodes.json")) fs.writeFileSync("./stats/episodes.json", "{}");
if (!fs.existsSync("./stats/buttons.json")) fs.writeFileSync("./stats/buttons.json", "{}");
if (!fs.existsSync("./stats/menu.json")) fs.writeFileSync("./stats/menu.json", "{}");
if (!fs.existsSync("./stats/queries.json")) fs.writeFileSync("./stats/queries.json", "{}");
@@ -40,6 +41,7 @@ global.spoils = JSON.parse(fs.readFileSync("./user/spoilers.json").toString());
global.servers = JSON.parse(fs.readFileSync("./user/servers.json").toString());
global.statsCommands = JSON.parse(fs.readFileSync("./stats/commands.json").toString());
global.statsPonies = JSON.parse(fs.readFileSync("./stats/ponies.json").toString());
+global.statsEpisodes = JSON.parse(fs.readFileSync("./stats/episodes.json").toString());
global.statsButtons = JSON.parse(fs.readFileSync("./stats/buttons.json").toString());
global.statsMenu = JSON.parse(fs.readFileSync("./stats/menu.json").toString());
global.statsQueries = JSON.parse(fs.readFileSync("./stats/queries.json").toString());
diff --git a/commands/episode.js b/commands/episode.js
index bf5b9f2..d6113a4 100644
--- a/commands/episode.js
+++ b/commands/episode.js
@@ -10,6 +10,13 @@ module.exports = async (interaction) => {
let select = interaction.options.getSubcommand();
let episode = interaction.options.getString('episode').toLowerCase();
+ if (statsEpisodes[select + "-" + episode] !== undefined) {
+ statsEpisodes[select + "-" + episode]++;
+ } else {
+ statsEpisodes[select + "-" + episode] = 1;
+ }
+ fs.writeFile("./stats/episodes.json", JSON.stringify(statsEpisodes), () => {});
+
let sdata = series.filter(i => i.command.toLowerCase() === select)[0];
if (typeof episode === "string") {
await episodeReply(interaction, select, episode, sdata);