Skip to content

Commit 11b24ac

Browse files
committed
chore: adjust CH script to remove past bot messages
1 parent e7bbf5c commit 11b24ac

1 file changed

Lines changed: 17 additions & 16 deletions

File tree

src/scripts/fetchDiscord.ts

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,14 @@ function processMessages(messages: Message[]) {
108108

109109
messages.reverse().forEach((message: Message) => {
110110
const key = message.author.id
111+
const isBot =
112+
message.author.bot ||
113+
message.author.username === 'Payload-Bot' ||
114+
message.author.username.includes('Bot')
115+
116+
if (isBot) {
117+
return
118+
}
111119
if (mergedMessages.has(key)) {
112120
const prevMessage = mergedMessages.get(key)
113121
prevMessage.content += `\n\n${message.content}`
@@ -140,21 +148,14 @@ function createSanitizedThread(thread: Thread, messages: Message[]) {
140148
}
141149
: {},
142150
messageCount: combinedResponses.length,
143-
messages: combinedResponses.map(({ attachments, author, content, timestamp }) => {
144-
if (author.username === 'Payload-Bot') {
145-
// Skip Payload bot messages
146-
return
147-
} else {
148-
return {
149-
authorAvatar: author.avatar,
150-
authorID: author.id,
151-
authorName: author.username,
152-
content: toHTML(content),
153-
createdAt: new Date(timestamp),
154-
fileAttachments: attachments,
155-
}
156-
}
157-
}),
151+
messages: combinedResponses.map(({ attachments, author, content, timestamp }) => ({
152+
authorAvatar: author.avatar,
153+
authorID: author.id,
154+
authorName: author.username,
155+
content: toHTML(content),
156+
createdAt: new Date(timestamp),
157+
fileAttachments: attachments,
158+
})),
158159
ogMessageCount: thread.message_count,
159160
}
160161
}
@@ -199,7 +200,7 @@ async function fetchDiscord() {
199200
.then((data) =>
200201
data.docs.map((thread) => ({
201202
id: thread.discordID,
202-
messageCount: thread.ogMessageCount || 0,
203+
messageCount: 0,
203204
})),
204205
)
205206

0 commit comments

Comments
 (0)