Discord bot down


#1

My project is called malaria. After about 5 minutes my discord bot goes offline. And I have added things in watch.json and have uptime robot. I need help.


#2

Here is a helpful guide written by another user. You can find it here:


#3

It might be helpful to know what your UptimeRobot config looks like, but based on the contents of your bot’s logs I don’t see it going offline every 5 minutes - it looks like it’s pretty constantly up to me.

What is the basis of your impression that it’s stopping every 5 minutes?


#4

My project is live but on discord it is offline. I don’t know the reason for that.


#5

Ah, interesting. I guess I’ll give the Discord experts a change to weigh in since they’re probably more likely to be able to help, but what I was seeing in the logs also sort of looked like it was running in Discord as well - at least the “reconnecting” event seems to be being fired, which I would have thought would be coming from Discord…


#6

Are there anything in logs? Or show a screenshot of code.


#7

It just fires the reconnecting event every second.


#8

That’s weird, have you tried using

const Discord = require("discord.js");
const client = new Discord.Client();
 
client.on("ready", () => {
  console.log("I am ready!");
});
 
client.on("message", (message) => {
  if (message.content.startsWith("ping")) {
    message.channel.send("pong!");
  }
});
 
client.login("SuperSecretBotTokenHere");

(Pinched from http://anidiots.guide/first-bot/your-first-bot)

Just to see if it’s the module’s problem?


#9

What do you mean? I do have a ping command but what about that?


#10

Hmm show us your watch.json please, just to make sure it’s not an infinite loop or something lol

PS: I used to have my bot write to a file on start, so Glitch automatically restarted over and over haha took me a long time to realise the issue


#12

So it seems like you have a xp.json which keeps tracks of the amount of messages users have sent. Messages are almost always being sent I’m assuming…? So xp.json will constantly get updated, causing your project to constantly restart.

Add all the files that are getting changed a lot into watch.json, excludes
image

{
  "install": {
    "include": [
      "^package\\.json$",
      "^\\.env$"
    ]
  },
  "restart": {
    "exclude": [
       // here
    ],
    "include": [
      "\\.js$",
      "\\.json"
    ]
  },
  "throttle": 900000
}

Maybe this: “\.json” is the issue? I have no idea about regex or whatever that is, so I don’t know if it matches the json files

But it seems like you have set a high throttle which causes the project not to restart…? Weird:/

Maybe you hit the 1000 logins per day?

Note: After 1000 Logins per day, your discord bot token will no longer work and you will have to make a new one.
Note: Please add your Discord bots list token to the .env file

PS: Also can you show us a screenshot of it saying reconnecting in the console? (Are there any errors, or is it just saying reconnecting)


#13

Just saying reconnecting.


#14

I’ve done what you did above but it is still offline.


#15

It’s good now because now it’s online. I don’t even know what happened.


#16

Then it went offline next minute.


#17

You can check for these events:
image
Might log more useful info as I have no idea what’s happening either




etc…


#19

I added the debug event. After my bot goes offline it says debugging... at ${new Date}.

I didn’t add the resumed event yet.


#20

This should do

client.on("warn", data => console.log(data));
client.on("disconnect", data => console.log("Bot is disconnecting..."));
client.on("reconnect", data => console.log("Bot is disconnecting..."));
client.on("error", data => console.log(data));

Can you paste a screenshot of logs when bot goes offline.

WARNING:
Debug event outputs your bot token censor before posting


#21

I have the above but how do I check for debug?


#22
client.on("debug", data => console.log(data));

Should work