You are browsing as a guest. Sign up (or log in) to start making projects!

Open comments for this post

16m 58s logged

🚀 Cosmo Bot Update: New Commands & Core Features

I have been spending a lot of time trying to make Cosmo feel like an actual interactive, instead of just blank script. I finally got a bunch of custom slash commands working in my Slack workspace, but man, getting here was a bit of a headache.

🛠️ What was built

  • /csb-ping - Just simple command to check the latency of bot response. Used to make sure the bot is working and not crashed.
  • /csb-catfact & /csb-joke - I have added these for a bit random fun. It just instantly give you a cat-fact and a joke.
  • /csb-apod - This was the biggest task to code but it is easily one of coolest feature. It pings NASA’s Astronomy Picture of the Day API and give you Title, Image and Description of APOD.

At first, dealing with external JSON payloads was a mess. I kept hitting API errors trying to parse NASA’s response. I had to figure out how to manually dig into the JSON, extract the exact image URL, title, and description, and then map it into JavaScript. As NASA send it’s API data little slowly if many accessed at same time. So I add a wait period of 3s. So if it get the repose it displays it, if it throws a fails to fetch.

1
50

Comments 0

No comments yet. Be the first!