Discord and Roblox Bot Feedback

I was wondering if you guys could give me some feedback on my Discord - Roblox bot. The bot is connected to each other. If you don’t know what I mean I am trying to explain that the bot is connected from discord to roblox using the API. My bot sends Roblox Group Shouts to Discord in an Embed and it also deletes Group Wall posts that contain the blacklisted words that are in the Javascript file.

Discord Bot
image

Roblox Bot
image

image

I used discord.js and noblox.js

Edit: I moved my bot onto Replit so I can send HTTP Request for my In-game ranking commands.

3 Likes

Looks great! In short, there is nothing to give feedback to a project that looks fine and works great.

1 Like

Feedback on your code:

  1. This code has a memory leak: Every time the bot state changes to ‘ready’ (even after disconnecting and connecting again normally), it will reinitialize your long polling, thus increasing the chance of rate limiting and decreasing efficiency overall. Consider changing bot.on to bot.once.

  2. Consider pressing Ctrl + Shift + F to automatically format your code.

  3. Add schema verification or error handling to all of your API requests, otherwise an internal server error or improper response from a remote server may cause your process to exit. If you are too lazy for this, consider using a daemon that automatically restarts the program.

  4. This is not feasible for a production environment as Roblox will start rate limiting your requests at some point (depending on polling delay, it will take longer or shorter for Roblox to start rate limiting your IP Address). Consider increasing the polling time inside the noblox.js module or using proxies if you need quick embeds.

  5. Consider removing “Username Logged In”, it serves little to no purpose in a production environment.

  6. Consider importing configuration like this:

const { Cookie, GroupID } = require('./config.json')
  1. Consider combining your time import into line 2.
  2. Consider defining your static functions GetAvatarURL outside of the looping function.

Thanks for your feedback. But I currently don’t see any issues with it. It is very fast at responding and Roblox didn’t rate limit anything.

1 Like

Also, I don’t think I need to import the Cookie and GroupID from the config file because it already knows where it is by just doing
const config = require(’./config.json’)

1 Like

What @Watercoolings was saying is that instead of defining the config var and them needing to do config.someProperty you can just directly get someProperty from the config file. This is called object destructuring.

You can learn about it here:

Ok, thanks! I did add a Promote command to promote users in the Roblox group from Discord.

image

It only fails if the user is at the Max Rank as shown below:

If they aren’t at the Highest Rank it will rank them.

Each time you use the command in Discord it goes up by 1 rank at a time.

Memory leaks are a serious issue. If you don’t address it ASAP and figure out how to avoid them, your finishing code will turn out very costly in terms of resources (VPS prices potentially).

What do you mean memory leaks? Please elaborate.

In simple terms, a memory leak occurs when your code keeps increasing ram usage without letting go of the ram that is no longer in use or redundant. After a while, this ram usage exceeds the allocated amount for node, or even the system, and then can cause other programs (or itself) to crash. Process monitors like nodemon and PM2 will also stop working if a memory leak occurs; your application will go down after running for a couple hours and nothing will restart it.

A memory leak is the gradual deterioration of system performance that occurs over time as the result of the fragmentation of a computer’s RAM due to poorly designed or programmed applications that fail to free up memory segments when they are no longer needed. Garbage collection is the even stranger term given to the automated process, found in some systems and languages, whereby memory space no longer needed by current applications is consolidated and freed up for reuse.
Russell Kay, computerworld.com

1 Like

Hello, The memory leaks that you mentioned started taking a hit on my Bot. Do you have any suggestions on how to fix that? Like how would I apply the polling times? Thanks!