aboutsummaryrefslogtreecommitdiff
path: root/174bg/discord-bot/source/commands/clear-cache.js
diff options
context:
space:
mode:
Diffstat (limited to '174bg/discord-bot/source/commands/clear-cache.js')
-rw-r--r--174bg/discord-bot/source/commands/clear-cache.js27
1 files changed, 27 insertions, 0 deletions
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,
+ });
+ }
+ },
+};