Skip to content

Commit

Permalink
hardening and adding debugging message history (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
bthomas2622 authored Jan 3, 2024
1 parent 0e79beb commit e470f1c
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions bot-scripts/message-history.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit e470f1c

Please sign in to comment.