I am currently writing a Discord bot and have reached the point of needing a refactor. With this being my first stab at JavaScript/NodeJS and making a bot in general, there are a lot of mistakes I made along the way that now need correcting. With this in mind, I have been trying to figure out all of the things that I should correct during this process. My current quandary follows, and has been bugging me for a few days.

I am using a NodeJS library, Eris, quite extensively. Since it represents the main structure of my bot, I tied a number of (singleton) objects and functions to it (e.g. database and logger reference, custom command for sending message, etc.).

The first question here is whether this is reasonable design, which I think is justified by removing items from the global scope (please do correct this assumption if this is bad practice in JS). The second question becomes, should I just extend the class offered by the library to "inherently" include these functionalities? Or is some other solution better (i.e. attaching objects once the class is instantiated, just using globals, creating a separate class that gets passed around and handles these functionalities, etc.)?


Writing this out helped my understanding. This really comes down to not relying on a library that you don't control. Better to make your own solution to the problem.

  • 1
    That's usually my approach :) I think that approach has the best snowball effect :) – superhero Jun 25 '18 at 9:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.