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

Open comments for this post

1h 10m 28s logged

Development Diary #2 - New commands for the bot

Today, I dedicated some time to improving my Slack bot and learning more JavaScript.

One of the main changes was in the math commands. Before, I had separate commands for addition, subtraction, multiplication, and division (/sum, /sub, /multi, and /div). They worked, but maintaining several commands for such similar operations didn’t make much sense. After learning how to use split() in JavaScript, I managed to combine everything into a single command, /my-calc, which performs the operation according to the operator entered by the user.

I also added some new commands to make the bot more fun to use. /my-roll generates a random number between 1 and 100, /my-coinflip simulates flipping a coin, /my-hello greets the user, and /my-tabuada displays the multiplication table of a number.

In making these changes, I practiced several things I’m learning in JavaScript, such as working with user input, converting text to numbers, using loops, conditionals, and generating random numbers with Math.random().

I also removed the /joke command. For now, I want to focus more on improving the bot’s foundation before adding features that rely on external APIs.

Overall, this update not only added new commands but also helped me better understand JavaScript and organize the code more effectively.

In the coming days, I intend to improve command validation, organize the project into separate files, get the bot running 24/7 on Nest, and continue adding new features.

English translation with the help of Google Translate.

0

Comments 0

No comments yet. Be the first!