From c6c9ad5d948a38c05e6a7d75097ca8a54c5a33ae Mon Sep 17 00:00:00 2001 From: "Alex Pooley (@zuedev)" Date: Wed, 22 Jul 2026 15:48:31 +0100 Subject: implement caching for uex --- 174bg/discord-bot/source/commands/clear-cache.js | 27 ++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 174bg/discord-bot/source/commands/clear-cache.js (limited to '174bg/discord-bot/source/commands/clear-cache.js') diff --git a/174bg/discord-bot/source/commands/clear-cache.js b/174bg/discord-bot/source/commands/clear-cache.js new file mode 100644 index 0000000..ad99723 --- /dev/null +++ b/174bg/discord-bot/source/commands/clear-cache.js @@ -0,0 +1,27 @@ +import { SlashCommandBuilder, PermissionFlagsBits, MessageFlags } from "discord.js"; +import fs from "fs"; + +export default { + data: new SlashCommandBuilder() + .setName("clear-cache") + .setDescription( + "Clears the bot's cache.", + ) + .setDefaultMemberPermissions(PermissionFlagsBits.Administrator), + execute: async (interaction) => { + const cacheDir = ".cache"; + + if (fs.existsSync(cacheDir)) { + fs.rmSync(cacheDir, { recursive: true, force: true }); + await interaction.reply({ + content: "Cache cleared successfully.", + flags: MessageFlags.Ephemeral, + }); + } else { + await interaction.reply({ + content: "Cache directory does not exist.", + flags: MessageFlags.Ephemeral, + }); + } + }, +}; -- cgit v1.2.3