-
| Can I react chat from the old chat until recently on a specific channel? |
Beta Was this translation helpful? Give feedback.
Answered by rigwild Sep 11, 2022
Replies: 1 comment
-
| Using the code example from the README. To add reaction(s), use Stop with { id() let channelId = cid let amount = 99999999 let delayMs = 500 let reactions = ['🤔', '🔥'] let reactionFn = api.addReaction // or api.deleteReaction let beforeMessageId = '8999999999999999999' // Leave it like this to react from latest let count = 0 var loop = true while (loop) { const messages = await api.getMessages(channelId, 100, { before: beforeMessageId }) // We reached the start of the conversation if (messages.length < 100 && messages.filter(x => x.type === 0 || x.type === 19).length === 0) { loop = false console.log(`[${count}/${amount}] Reached the start of the conversations! Ending.`) continue } // Update last message snowflake for next iteration beforeMessageId = messages[0].id for (const aMessage of messages) { if (loop === false) break // Check if the max amount was reached if (count >= amount) { loop = false console.log(`[${count}/${amount}] Reacted the requested amount of messages! Ending.`) break } // Update last message snowflake for next iteration beforeMessageId = aMessage.id // Check if the message should be reacted if (aMessage.type === 0 || aMessage.type === 19) { for (const reaction of reactions) { await reactionFn(channelId, aMessage.id, reaction) await delay(delayMs) } count++ console.log(`[${count}/${amount}] Treated a message! ID=${aMessage.id}`) if (count < amount) await delay(delayMs) } } await delay(delayMs) } } |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by rigwild
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Using the code example from the README.
Supports multiple reactions, scans all messages from the last
To add reaction(s), use
let reactionFn = api.addReactionTo delete reaction(s), use
let reactionFn = api.deleteReactionStop with
loop = false