2

First off, I would like to say, I know very little coding, so please bear with me here.

Introduction

Despite not knowing any coding, I decided to make a discord bot for the fun of it. I also don't have any money, so I can't buy any fancy servers or software, so I started making it on replit. The bot is all done, and it doesn't do much really, just sends an embed on seeing a command, and I've set up a command handler and everything.

Problem

The problem I'm having is, it keeps going offline. Before it would go offline after a few hours, but I tested it recently, and it went out in around 20 minutes. There's no error or anything, just when I open up replit its off and I have to run it again.

Troubleshooting

I looked online, but all of those said to get a server and hook it up to uptimerobot, or have keepAlive(), but I have already had all this since the beginning. I even checked uptimerobot and it hasn't lost connection once in the past 2 weeks.

To test this, I made another quick discord bot, with only a ping command, and after 3 or so days, it has yet to go off. So I'm thinking that the problem might be I have too many commands (105 to be exact) for the basic replit resources to handle, but I'm not sure.

No one has even used the bot when it goes offline, so I really don't know what to do.

Any help would be great.

Thanks

  • Use heroku for free nodejs hosting. You get what you pay for, if you don't want to pay for something don't expect it to be good. – Asplund Apr 20 '22 at 10:31
  • 1
    There's a paid feature on repl.it called "ALWAYS ON" you should use it to keep the repl alive. after all repl.it is only an online code editor and not suggested for production grade hosting. Use an "actual hosting provider" instead – Akio Apr 20 '22 at 11:07
  • I think the problem is you have too much in memory and repl is turning off your instance. – Liam Apr 20 '22 at 13:12
  • I imagine repl processes fall asleep after inactivity – Elitezen Apr 20 '22 at 14:29

3 Answers3

2

I would not recommend using uptime robot to host those replits because they only check ever 5 minutes (if you dont want to pay). I would rather use https://www.freshworks.com/website-monitoring because it has a 1 minute keepalive.

Robbour2
  • 31
  • 8
1

I won't suggest repl.it if you want to host your discord bot. Some good alternatives would be Heroku and Railway. I would personally suggest Railway (https://railway.app)

(Do note: you need to learn git and GitHub if you are going to use either of this platforms, and of course you need to learn them either way at a later date.)

(Also do note that I don't really suggest using these free hosters, get a paid vps, or keep using this.)

Ren Hiyama
  • 383
  • 2
  • 13
0

Replit's free plan doesn't allow 24/7 hosting

But there is a trick!

Add this to your code

const express = require("express")
const app = express()

const server = app.listen(3000, () => {
    console.log(`Express running → PORT ${server.address().port}`)
})

app.get("/", (req, res) => {
    res.send("Online!")
})

Then copy your replit link and use a service which periodically pings your repl project to do that, here's a video of how to do it https://youtu.be/wZbAinOmays

How it works

Express is a package used for making HTTP servers and if you make a request to the HTTP server periodically, replit won't stop your project.

I would still use a paid service, because as others pointed out, you get what you pay for

Mushroom idiot
  • 39
  • 3
  • 10