Skip to content

Commit

Permalink
Merge pull request #83 from berkingurcan/fix-deletin-response-button
Browse files Browse the repository at this point in the history
fix respond message delete
  • Loading branch information
berkingurcan authored Oct 17, 2024
2 parents 5277101 + 5a579c7 commit c177122
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/lib/startAutoPosting.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.`);
Expand All @@ -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) {
Expand Down

0 comments on commit c177122

Please sign in to comment.