From 9da39df8fc33026b284d5ca4a4cf52ae84f14216 Mon Sep 17 00:00:00 2001 From: ethanf Date: Tue, 16 Jan 2024 17:07:14 -0600 Subject: [PATCH] feat: clear command --- index.js | 15 +++++++++++++++ register.js | 4 ++++ 2 files changed, 19 insertions(+) diff --git a/index.js b/index.js index 914c70a..f0adb5c 100644 --- a/index.js +++ b/index.js @@ -239,6 +239,21 @@ client.on("interactionCreate", async (interaction) => { ) ); } + if (command === "clear") { + await interaction.reply("clearing messages..."); + let channel = client.channels.cache.get(COMMAND_CHANNEL_ID); + if (!channel) return console.error("Can't find command channel"); + channel.messages + .fetch({ limit: 100 }) + .then((messages) => { + messages.forEach((message) => { + if (message.author.id === client.user.id) { + message.delete(); + } + }); + }) + .catch(console.error); + } }); client.login(TOKEN); diff --git a/register.js b/register.js index 62b97b1..e2cd2f8 100644 --- a/register.js +++ b/register.js @@ -26,6 +26,10 @@ const commands = [ name: "fk", description: "Pulls addup channel members into fk channel and lists them", }, + { + name: "clear", + description: "Clears bot messages in command channel", + }, { name: "scout", description: "Lists picking channel members with scout role",