Make a script (typescript for example) to store popular messages (messages with 5+ reactions) in the Firebase Firestore database. The idea is to have this info on a collection that the code in EddieBotUI will use to get the data for the popular messages web page.
This script would override all the data in the collection maybe. This is to avoid data inconsistencies since we could have run the script yesterday, and then the user of a popular message edits the message on discord. So we should update the contents on the DB when the script is ran.
The decision for only storing popular messages instead of all messages is that we don't need all that data plus data management costs.
Also, use the Discord API to get these messages with 5+ reactions, where the 5 should be parameterized on the script
We have an event that happens when there are more than 5 messages (high value role added to user), we could trigger from that and save that message?
I agree with using this event to push the message into firestore.
Roughly like this. I think there is a better way to choose which doc. Sorry for any errors.
const createMessage = async () => {
await db
.collection('messages')
.doc(reaction.message.author.id)
.set({
avatar: reaction.message.author.avatarURL(),
username: reaction.message.author.username,
message: reaction.message.content,
updatedAt: firebase.firestore.FieldValue.serverTimestamp()
}, { merge: true });
}
@eddiejaoude, @AllanRegush I agree we can do this on EddieBot, it's an awesome idea 馃憤. But this script was more geared to the messages that already have 5 reactions, so basically have all the popular messages since the server's inception/beginning 馃槃.
But a simpler version to start this feature off would be to add @AllanRegush suggestion 馃槂 .
This could be added to the 5+ reaction section, then it would only save the popular ones - would be good to keep the total of reactions, so we can sort on the reaction total
Stale issue message
@BOLT04 we have the 5+ reactions for this, do we still want to keep this issue or can we close it?
Yes, we can close this since we have the 5+ reactions section 馃憤