🇪🇸 Versión en español abajo
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 😅
I chose a tech stack I was already familiar with, although I hadn’t used it in a while:
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.
Since this was a pretty ambitious goal, I broke it down into smaller parts and started with:
/start/profile/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!
(A little spoiler here showing features I added later)
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.
I created my character with /start:
Then checked my stats using /profile:
And here’s a battle using /battle:
Since I had some free time left, I added a shop and inventory system!
/use command to consume items (potions, buffs, etc.)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!
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. 😅
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.
Ya que me puse un objetivo bastante ambicioso decidi dividirlo un poco y empezar por:
/start/profile/battleEl 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
(hice un poco de spoiler ya que estoy mostrando cosas que implemente despues)
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!
Cree mi perfil/personaje utilizando el comando /start
Luego con el comando /profile ya lo pude ver
y aca esta como se ve cuando combatis con el comando /battle
Como todavia tenia tiempo libre decidi implementar mas cosas como un mercado y el inventario!
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!