DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» is a community of 963,274 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
geneva
geneva

Posted on

Why Supernal is a Failure

I've released an announcement to my staff over at inkthought labs internally why I think that my 2 projects branded under inkthought labs are failures.

Giving some context to people who don't know what inkthought labs or the project is. Supernal is also a Discord bot with the concept of a non-bloated and fast solution to Discord tasks.

Here's an excerpt:

Supernal a bloated piece of s***. I'm astonished that I have hacked together such an unoptimised bot.

Let's talk about code bloat. In Supernal, this is the reminder function that executes every 5 seconds. It utilises a Mongoose "cursor" and a for loop, which basically loads all the documents to cache, and allows you to go through them one by one. Kind of like tabs in your browser.

Code Image

Already looking bloated.

Over 30 lines just for this.

Plus, it's located in the main file.

This is an unscalable solution to check a MongoDB database, which is not even located locally.

In Supernal code, there are a lot of lines to even process a command. That's why the ping is high, about a second to even process a command.

Although the project was bootstrapped with create-discord-app, I've since then added all kinds of junk to the main file, causing slow response speed. The "message" event runs through tons of checks - including whether you are blacklisted from using the bot and others. This queries a database, which again is async, which takes time. This completely slows down the process.

What can I do to solve this?

Perhaps by reducing the number of database queries. But then I'm not quite sure what to do with the reminder function. (Let me know in the comments). I could also fix the blacklist and prefix database query issue by using loading to the cache.

Now, the bot has detached from the original idea of a non-bloat.

I'll talk about my other bot in another article. See you then.

Top comments (0)

🌚 Browsing with dark mode makes you a better developer.

It's a scientific fact.