How to build this db model
Working on a NoSQL implementation of this discord bot me and my friend are setting up. What it'll do is iterate through all messages and get the amount of emojis each user has across all their messages.
I was wondering what a good model for this would be? Should we build a model for each User, and then iterate through all their emojis? I have this so far:
This way, we can just do something like:
13 Replies
Could you the counts of each emoji in your db? It seems like the list of emojis could get voluminous quickly.
You have to do a db update for each emojiing event anyway.
It'd definitely speed up the calculation.
(Also, your sort should return
userBCount - userACount
since it's expecting a positive, 0
, or negative value.)Hey dys! Do you mean I should get the count of a specific emoji in the backend instead of the frontend? e.g have an endpoint like
/get/emoji/:emojiId
and that way we're limiting the amount of work the bot has to do?I actually misread your code. Because you used an array, I assumed you were tracking all the emojis in a list.
Your structure is actually what I was suggesting. πΈ
How I'd change what you have is to use a map, so you have
user.emojiCount = { chart: 10, β¦ }
(so you can call user.emojiCount['chart']
) rather than user.emojis = [{ emoji: 'chart', count: 10 }, β¦]
& have to find the count.No worries π and that's smart! I'll try that, thank you!! π
yeah, I like the change for a list to a map that @dys π suggested.
How will the bot function?
I'm guessing something like this?
!count username emoji and it'll return the count for that user?
How will the bot function?
I'm guessing something like this?
!count username emoji and it'll return the count for that user?
Well, probably
/count
since slash commands are listed by the system & autocomplete.Yup exactly like dys said! We used to have to do !count syntax but thank god there's slash commands now haha
To be more specific, we'll probably just do something like
/leaderboard <emoji-name>
and it'll give us a sorted list of who has the most emojis on their messages
At least for an mvp, we're just having fun with it right now πMy buddy made a chat bot for our friend group Keybase channel. Itβs pretty good. Does TLDR, imbeds YouTube, keeps score of polls, etc.
Always a fun project
That sounds awesome! Do you guys have a git repo of it I could take a peak at?
No problem @vince here is his repo - https://github.com/pastorhudson/mtb-pykeybasebot
GitHub
GitHub - pastorhudson/mtb-pykeybasebot: Python Keybase Bot Library
Python Keybase Bot Library. Contribute to pastorhudson/mtb-pykeybasebot development by creating an account on GitHub.
Thank you!! :)
Anytime. If you have questions just let me know. I've only done a little bit of work with it, I'm more of a Java guy instead of Python. But I'll either look into or get ya the answer.
That's so nice, thank you! I'll let you know