Ruby

Free Ruby Discord bot hosting.

discordrb on a current Ruby, with Bundler installing your gems when the server starts. Add a Gemfile, name your entry file, press start.

Libraries

Libraries that run here

discordrb

The long-standing Ruby library for the Discord gateway, with commands, events, slash commands and voice. Declare the intents you need when you create the bot; the message content intent is a privileged one and has to be switched on in the developer portal.

Sinatra or Roda

For a bot that answers HTTP interactions instead of holding a gateway connection. A small Rack app is plenty, though it needs a public address for Discord to call, which a gateway bot does not.

Anything on RubyGems

Bundler reads the same Gemfile you use on your own machine. Pure Ruby gems install at once; gems with native extensions compile first, which the image has the tools for.

Deploying

Getting it running

  1. 1

    Upload your project

    Drag the folder into the file manager or push it over SFTP. Gems install into a folder inside your server, so there is no need to upload a vendor directory. discordrb has to be listed in the Gemfile for the bot to find it.

  2. 2

    bundle install runs for you

    When a Gemfile is present, Bundler installs it before the bot starts and skips the install on later restarts until the Gemfile changes. discordrb is pure Ruby apart from a few dependencies, so a first install is usually quick.

  3. 3

    Point us at your entry file

    bot.rb or main.rb. Your token goes into an environment variable and is read with ENV.fetch, which fails loudly at start-up if you forgot to set it.

Memory

What actually fits in 256 MB

A discordrb bot is comfortable in 256 MB for a few hundred servers. Ruby's own footprint is a little larger than a small Node process, and most of the rest is the cache the library keeps of the servers, channels and members it is shown.

Request only the intents you use and keep the member cache off unless the bot needs it, before blaming the limit. Gems install into your server's own disk, so a large Gemfile also eats into your 512 MB; bundle only what the bot loads. A music bot will not fit here in any language.

FAQ

Questions

Which Ruby version should I pick?

The newest your gems support. Ruby 4.0 and 3.4 are the safe starting points for a new bot, and 3.3 or 3.2 are there for projects pinned to an older version. The version is chosen on the server's startup page.

Is discordrb still maintained?

It is released less often than discord.js, so check the repository and the version your Gemfile resolves to before you start. Slash commands and the current gateway are supported, but a very new Discord feature can take a while to arrive.

Do gems with native extensions work?

Yes for the common ones. The image has a compiler and the headers for SQLite, PostgreSQL, MariaDB, libxml and OpenSSL, so gems such as nokogiri, pg, mysql2 and sqlite3 build when bundle install runs. The first start after you change your Gemfile takes longer while they compile; later starts skip the install.

Where should the secrets live?

In environment variables set on the server, read with ENV.fetch. A .env file uploaded with your code sits in your file manager like any other file, and Ruby does not read one by itself unless you add a gem such as dotenv for it.

Free tools for Discord bots