From 5a579c76c3700155ece7b88b7549831d6488cb0c Mon Sep 17 00:00:00 2001 From: berkingurcan Date: Thu, 17 Oct 2024 10:43:35 +0700 Subject: [PATCH] fix respond message delete --- src/lib/startAutoPosting.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/lib/startAutoPosting.js b/src/lib/startAutoPosting.js index 25b4b4e..9107102 100644 --- a/src/lib/startAutoPosting.js +++ b/src/lib/startAutoPosting.js @@ -62,8 +62,16 @@ export const startAutoPosting = async (client, redisClient) => { if (botMessages.size > 0) { for (const [messageId, message] of botMessages) { - await message.delete(); - log.debug(`Deleted bot message: ${messageId}`); + const hasButtons = message.components.some(row => + row.components.some(component => component.type === 2) + ); + + if (!hasButtons) { + await message.delete(); + log.debug(`Deleted bot message: ${messageId}`); + } else { + log.debug(`Skipped deleting bot message with buttons: ${messageId}`); + } } } else { log.debug(`No bot messages found in the thread.`); @@ -72,6 +80,7 @@ export const startAutoPosting = async (client, redisClient) => { } catch (error) { log.error(`Error deleting bot messages: ${error.message}`); } + for (const [i, toSend] of Object.entries(messagesToSend)) { if (i == 0) {