
<small><sub>🇪🇸 Versión en español abajo</sub></small>
## <center>Hey Hive!</center>
This weekend I decided to explore a skill I had been curious about for a while: **creating a Discord bot.**
I know many popular bots combine useful features with game mechanics, so I wanted to see how they actually work.
I wasn’t very cautious when choosing the difficulty, and for my very first project, I decided to build… an **RPG bot** 😅
---
### What did I use to build it?
I chose a tech stack I was already familiar with, although I hadn’t used it in a while:
- Node.js as the main engine
- discord.js v14 to implement the bot
- MongoDB Atlas to store user progress
If it happens to you: I had a small issue connecting to the database. It turned out to be a problem with the user I was using (created for another DB). I solved it by creating a new one with proper access.
---
### First features
Since this was a pretty ambitious goal, I broke it down into smaller parts and started with:
- Create your character with `/start`
- View your stats with `/profile`
- Fight enemies in turn-based battles using `/battle` (costs energy)
The development of these first commands was quite smooth. I hadn’t used Node.js in a while and forgot how much I loved its modular folder structure!
<center>
*(A little spoiler here showing features I added later)*</center>
The bot uses `index.js` to start up, listen for commands, and connect to the database.
Inside the `commands` folder are all the bot commands and logic.
The `models` folder contains the `Player` model that defines the data saved to the database.
---
### Let’s see the bot in action!
1. I created my character with `/start`:
<center></center>
2. Then checked my stats using `/profile`:
<center></center>
This was the first version. Later, I upgraded the embed to look cleaner and more professional:
<center></center>
3. And here’s a battle using `/battle`:
<center>
*We fought a slime and won!*</center>
---
### Bonus: Shop & Inventory
Since I had some free time left, I added a shop and inventory system!
<center>
</center>
---
## Coming Soon
- `/use` command to consume items (potions, buffs, etc.)
- Cooldowns and daily rewards
- More items, enemies, and levels
- Hive integration? 👀
---
I’m super happy with how much I learned and built in just a few days. I’ll keep improving the bot in my spare time and maybe release other prototypes.
If you have any ideas for this bot or other bot projects, feel free to share them in the comments — I’d love to hear your thoughts!
Thanks for reading, and see you in the next post!
---
### <center>🇪🇸 ESPAÑOL</center>
---
## <center>Hola Hive!</center>
Este fin de semana decidí explorar una habilidad que hace rato me daba curiosidad: **crear un bot para Discord.**
Sabía que muchos bots populares combinan funciones útiles con mecánicas de juego, así que decidi ver como funcionan.
No fui muy prudente en cuanto a dificultad del juego y decidi como primer proyecto desarrollar un bot para un juego RPG. 😅
### ¿Qué usé para construirlo?
Elegí un stack que conocía pero no utilizaba hace un tiempo:
- Node.js como motor principal
- discord.js v14 para implementar el bot
- MongoDB Atlas para guardar progreso de los jugadores
Por si les pasa tuve un pequeño problema inicial conectándome a la base de datos, era un problema con el usuario que queria utilizar(era un usuario que habia creado para otra base de datos) y se soluciono creando uno nuevo.
### Primeras funcionalidades
Ya que me puse un objetivo bastante ambicioso decidi dividirlo un poco y empezar por:
- Creacion del personaje `/start`
- Poder ver tu perfil con tus stats `/profile`
- Poder pelear con algun enemigo en batalla por turnos y consume energia `/battle`
El desarrollo de estos primeros comandos la verdad que fue bastante simple y directo. Hace tiempo que no usaba Node JS y me habia olvidado lo mucho que me gustaba la estructura modular de archivos y carpetas
<center>
*(hice un poco de spoiler ya que estoy mostrando cosas que implemente despues)*</center>
el bot utiliza `index.js` que funciona como encendido del bot para escuchar y cargar los comandos y tambien conectarse a la base de datos
luego en la carpeta `commands` tenemos todos los comandos con su logica
y en la carpeta `models` el modelo de `Player` que funciona como estructura de datos que se guarda en la base de datos
Terminando con los tecnicismos miremos al bot en accion!
1. Cree mi perfil/personaje utilizando el comando `/start`
<center></center>
2. Luego con el comando `/profile` ya lo pude ver
<center></center>
Esta fue la primer version pero luego agregue mas detalles para que se vea mucho mas estetico y profesional
<center></center>
3. y aca esta como se ve cuando combatis con el comando `/battle`
<center>
*Combatimos un slime y ganamos!*</center>
### Bonus
Como todavia tenia tiempo libre decidi implementar mas cosas como un mercado y el inventario!
<center>
</center>
## Proximamente
- Comando /use: consumir ítems del inventario (pociones, mejoras, etc.)
- Cooldowns y recompensas diarias
- Más ítems, enemigos, niveles
- Integracion con Hive? 👀
Estoy muy contento con lo desarrollado hasta ahora. Voy a seguir mejorando el bot en mi tiempo libre y probablemente haga otros prototipos. Si tienen alguna idea para el bot u otro bot dejenla en los comentarios me encantaria leerlas!
Gracias por leer y nos vemos en el siguiente post!