From 0425c84eded10decd4e4c235f4ebd116fddd1d10 Mon Sep 17 00:00:00 2001 From: bthomas2622 Date: Tue, 2 Jan 2024 19:42:09 -0800 Subject: [PATCH] hardening message history --- bot-scripts/message-history.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/bot-scripts/message-history.js b/bot-scripts/message-history.js index 852ea7d..c56d857 100644 --- a/bot-scripts/message-history.js +++ b/bot-scripts/message-history.js @@ -13,10 +13,17 @@ async function fetchMessageHistory(client, snowflakeTime) { const channels = Array.from(client.channels.cache.values()); for (const channel of channels) { - const channelMessages = await channel.messages.fetch({ after: snowflakeTime }); + if (channel.isTextBased()) { + try { + const channelMessages = await channel.messages.fetch({ after: snowflakeTime }); - for (const message of channelMessages.values()) { - messagesArray.push(message); + for (const message of channelMessages.values()) { + messagesArray.push(message); + } + } catch (error) { + console.error(`Error fetching messages for channel ${channel.name}`); + console.error(error); + } } } } catch (error) {