/* * MIT License * * Copyright (c) 2022- Minteck * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * */ const fs = require('fs'); const {MessageActionRow, MessageButton, MessageSelectMenu, MessageEmbed} = require('discord.js'); const admin = fs.readFileSync("./config/admin.txt").toString().trim(); const list = Object.keys(JSON.parse(fs.readFileSync("./data/data.json").toString())); const getResult = require('../modules/result'); const getEmbed = require('../modules/embed'); const getPixel = require("../modules/pixel"); const official = fs.readFileSync("./config/official.txt").toString().replace(/\r\n/g, "\n").split("\n"); const fpserver = fs.readFileSync("./config/fpserver.txt").toString().trim(); const commandRandom = require('../commands/random'); const commandInfo = require('../commands/info'); const commandEval = require('../commands/eval'); const commandConfig = require('../commands/config'); const commandPony = require('../commands/pony'); const commandEpisode = require('../commands/episode'); const commandHelp = require('../commands/help'); module.exports = async (interaction) => { console.log(interaction.user.tag + " (" + interaction.user.id + ") used command /" + interaction.commandName); if (statsCommands[interaction.commandName] !== undefined) { statsCommands[interaction.commandName]++; } else { statsCommands[interaction.commandName] = 1; } statsCommands["_total"] = Object.keys(statsCommands).filter(i => i !== "_total").map(i => statsCommands[i]).reduce((a, b) => a + b); fs.writeFile("./stats/commands.json", JSON.stringify(statsCommands), () => {}); if (statsHour[new Date().getUTCHours().toString()] === undefined) { statsHour[new Date().getUTCHours().toString()] = {}; } if (statsHour[new Date().getUTCHours().toString()][interaction.commandName] !== undefined) { statsHour[new Date().getUTCHours().toString()][interaction.commandName]++; } else { statsHour[new Date().getUTCHours().toString()][interaction.commandName] = 1; } statsHour[new Date().getUTCHours().toString()]["_total"] = Object.keys(statsHour[new Date().getUTCHours().toString()]).filter(i => i !== "_total").map(i => statsHour[new Date().getUTCHours().toString()][i]).reduce((a, b) => a + b); fs.writeFile("./stats/by-hour.json", JSON.stringify(statsHour), () => {}); if (statsDay[new Date().getUTCDay().toString()] === undefined) { statsDay[new Date().getUTCDay().toString()] = {}; } if (statsDay[new Date().getUTCDay().toString()][interaction.commandName] !== undefined) { statsDay[new Date().getUTCDay().toString()][interaction.commandName]++; } else { statsDay[new Date().getUTCDay().toString()][interaction.commandName] = 1; } statsDay[new Date().getUTCDay().toString()]["_total"] = Object.keys(statsDay[new Date().getUTCDay().toString()]).filter(i => i !== "_total").map(i => statsDay[new Date().getUTCDay().toString()][i]).reduce((a, b) => a + b); fs.writeFile("./stats/by-day.json", JSON.stringify(statsDay), () => {}); if (statsDate[new Date().toISOString().split("T")[0]] === undefined) { statsDate[new Date().toISOString().split("T")[0]] = {}; } if (statsDate[new Date().toISOString().split("T")[0]][interaction.commandName] !== undefined) { statsDate[new Date().toISOString().split("T")[0]][interaction.commandName]++; } else { statsDate[new Date().toISOString().split("T")[0]][interaction.commandName] = 1; } statsDate[new Date().toISOString().split("T")[0]]["_total"] = Object.keys(statsDate[new Date().toISOString().split("T")[0]]).filter(i => i !== "_total").map(i => statsDate[new Date().toISOString().split("T")[0]][i]).reduce((a, b) => a + b); fs.writeFile("./stats/by-date.json", JSON.stringify(statsDate), () => {}); if (interaction.commandName === 'random') { await commandRandom(interaction); } if (interaction.commandName === 'help') { await commandHelp(interaction); } if (interaction.commandName === 'info') { await commandInfo(interaction); } if (interaction.commandName === 'eval') { await commandEval(interaction); } if (interaction.commandName === 'config') { await commandConfig(interaction); } if (interaction.commandName === 'pony') { await commandPony(interaction); } if (interaction.commandName === 'episode') { await commandEpisode(interaction); } }