Rep Bot
- 5 Devlogs
- 6 Total hours
A bot that tracks which person has helped the most people in #hardware!
A bot that tracks which person has helped the most people in #hardware!
Eyyyy! Whatcha look at that! Editing the leaderboard works now.
so, I had to switch from using respond() to client.chat.update() which makes no sense to me but okay sure whatever it works now. Then, there was an error about duplicate action IDs which I used Gemini to figure out the fix for: Slack wants a unique action to be performed by each button so you need a new event handler. But I don’t want to duplicate code so I hovered over the “app.action” function and noticed that it except RegEx so I used the RegEx “/paginate_(next|prev)/”
I’m so happy it works now though. Time to ship it!
HEY GUESS WHAT THE ISSUE WAS. GUESS WHAT. IT. WAS. FIXED. WITH. A. REBOOT. WHAT
okay, so. Here’s the context, right. The user requests a command to be ran on the bot and the command is sometimes randomly delayed until after the 3 second timeout from Slack is over so Slack thinks the bot didn’t receive it but the bot didn’t even receive the command. I have a video attached.
I thought it was my code’s fault, so I was messing around and adding logging and changing random things and googling and whatnot and nothing fixed it. And then I rebooted my computer. AND IT FIXED IT WHAT DO YOU MEAN???? IF IT WAS AN ISSUE WITH THE NETWORK CODE WHY DIDN’T WEBSITES TAKE SECONDS TO LOAD???? THEY LOADED FINE! WHYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
So, I got the leaderboard working..kind of. The leaderboard works and shows the top 10 people, but the “Next” button to show the next 10 people doesn’t work. Why? Who knows? Slack just complains of something being wrong and doesn’t give many details about what exactly is wrong.
There’s also another issue: sometimes the bot won’t receive a message from Slack that a command was ran until after the timeout period of 3 seconds is over. And I know it’s not the code taking more than 3 seconds to run because the request is immediately ack’d and the entire code block takes less than 250ms on average (I timed it with console.time). So I have no idea what’s going on. That’s why this devlog is 2.5 hours. It took me 45 minutes to add the feature, and the rest of the time is trying to fix the feature. I’ll continue debugging it.
Added the /rep-bot-profile command which queries the database for your points + the amount of people that have more points than you and then tells you.
Next up: a leaderboard command
I got the bot working! People who say “thanks” or “thank” or “thx” followed by pinging someone will give that person 1 rep point.
I setup the SQLite database with Drizzle ORM.
I had lots of trouble with getting the bot to recognize that messages were even sent, so I went to Stardance’s slack bot guide for help with setting up my bot properly. I don’t know what exactly I changed to fix it, but the bot started recognizing new messages sent in the channel after I added all the permissions the guide said to add.