Memory leak in discord bot project


#1

Hey, I have a tiny bot running as an express app that has a few basic commands to assist me in my discord server, it’s having issues though, I get memory warnings from it, and every 15 seconds it sleeps because of it, it exceeds the 512 MB limit for some reason even though it’s just 40 lines of basic code that only has 3 libraries, discord.js, http and fs. Is this an problem with discord.js or a glitch issue?


#2

Hey @AquaticFish, from this information it’s hard to say where the actual memory problem is, but aside from the technical restrictions, it’s less likely that the problem is with Glitch than with how your bot is implementing discord.js. If you share your project name, someone might be able to give more specific feedback.


#3

Hey, here’s my code, https://pastebin.com/raw/YH26Z5Vf


#4

I don’t see anything obvious in there. I’m moving this topic to another category where other Discord bot authors might be able to help, but I’m not sure just seeing the code you’ve shared will be sufficient detail.


#5

Your code looks very different from other d.js codes i seen. I’m mostly confused at
if (message.author.id === “//”){
Try following the example they have on their npm page.


#6

It’s a line for checking if the message’s owner is me before proceeding, I removed my ID and replaced it with “//” for safety and privacy reasons.


#7

Instead of if (message.author,id === “//”) {,
Put:
if(!message.author.id === “//”) return;
this basically makes the bot not proceed when their id doesnt match yours.


#8

I know but that shouldn’t cause any of the issues I’m experiencing right now


#9

Still no solutions to this problem…


#10

Hello @AquaticFish, Can you verify that you are indeed using a bot, and not a user account token, as this sometimes can also be the problem, I have seen other people try self bots, and they would not work, if the account is not a bot account, also, try getting a new bot token, and try with that, and tell me the end result!


#11

If it was invalid, d.js would throw an error ‘invalid login credentials’


#12

I am not using a selfbot, also the issue disappeared randomly, weird.