This part of the series introduces Cozy Café, an idle Discord bot game where players manage a virtual café, earning coins and unlocking recipes even while offline. The game's design prioritizes rewarding presence over punishing absence, contrasting with games that induce guilt for inactivity. Instead of cramming all code into a single file, the project adopts a structured approach using a "separation of concerns" principle. This involves organizing commands into individual files within a commands/ directory, while core café data is temporarily stored in a data/store.js file using an in-memory Map. Each command file adheres to a consistent structure, exporting data (command name and description) and an execute function. The first two commands, /open and /cafe, are implemented, allowing users to start a café and check its status. Finally, the index.js file is upgraded to include a command handler, which automatically loads and registers all commands from the commands/ folder, routing user interactions to the correct command execution logic. This modular design ensures the bot can scale efficiently without becoming an unmanageable mess.
commands/directory, while core café data is temporarily stored in adata/store.jsfile using an in-memory Map. Each command file adheres to a consistent structure, exportingdata(command name and description) and anexecutefunction. The first two commands,/openand/cafe, are implemented, allowing users to start a café and check its status. Finally, theindex.jsfile is upgraded to include a command handler, which automatically loads and registers all commands from thecommands/folder, routing user interactions to the correct command execution logic. This modular design ensures the bot can scale efficiently without becoming an unmanageable mess.