Demo, all content is generated
Question

Replit asks Autoscale, Reserved VM or Static, which one for a Discord bot?

Solved · 1901 views · asked by moana_k · edited

My Discord bot for our football club (match reminders, a few commands). Works when I press Run. When I close the tab it goes offline. I want to deploy but don't understand the options, and I don't want a big bill.

What I’ve tried

Chose Autoscale because it was the default. The bot went offline after a few minutes and came back only when I opened the site URL.

Comment
Is the bot on discord.js? kofi_mensah · edited
yes, discord.js 14 moana_k · edited

3 answers

Marked as helpful by the asker
kofi_mensah · edited

Reserved VM. A Discord bot keeps an open connection (websocket) to Discord all day. Autoscale only runs while HTTP requests come in and scales to zero in between, so your bot dies when nobody visits the URL, which is exactly what you saw.

  • Autoscale: websites/APIs that answer requests.
  • Reserved VM: things that must run all the time (bots, workers).
  • Static: plain HTML/CSS/JS, no server.
  • Scheduled: run a script at set times.

Pick the smallest Reserved VM, a small bot barely uses anything. For the match reminders you could even use a Scheduled deployment that posts via a webhook, but then commands won't work.

Comment
Reserved VM smallest size, bot online for 2 days now. The cost is ok moana_k · edited
This list of 4 should be in the Replit docs in exactly this form amara_v · edited
jonas_k · edited

Also make sure the bot doesn't start a web server on some port unless you need it, Reserved VM for a bot doesn't need an exposed port. Some templates add an Express keep-alive server from the old 'ping it with uptimerobot' days, you can remove that.

Comment
the_real_omar · edited

Make sure the bot token is in the deployment's secrets, not only in the workspace ones. Took me an hour to figure out why mine wouldn't log in.

Comment
yes this was exactly the next problem I had haha moana_k · edited