Well, that depends a lot. The best ways to detect a memory issue is just really using a logger that logs everything you do, for example:
myLogger.debug("script is starting")
myLogger.debug("Adding a message hook.");
bot.on("message", async msg => {
myLogger.debug("Received message from %s", msg.author.tag);
// do stuff with message.
myLogger.debug("Handled message from %s", msg.author.tag);
});