Deploy a Discord.js Bot for Production

Lucas Minter
InstructorLucas Minter
Share this video with your friends

Social Share Links

Send Tweet
Published 2 years ago
Updated 2 years ago

The final step we need to take is to deploy our Discord bot to production. We'll be using using GitHub and Railway.app.

Railway.app is a deployment platform that allows us to deploy our bot to the cloud. They give you $5 or 500 hours of free usage per month, which probably won't last you the full month, but it's a great way to get started.

Instructor: [0:01] Now that our bot is finished, let's deploy it. Over on GitHub, we're going to create a new repository. Paste the name of our book called bot. This will be public. Won't worry about anything else. Create repository.

[0:20] I'm going to go ahead and copy this, head back to our terminal, paste in that, hit enter. Let's do a Git status. We can see we have some files that we don't want to be committed.

[0:41] Let's create a new file called .gitignore. We want to ignore our .env, .vscode, and our node modules. Lastly, our yarn.lock. Save that, get status again, and you can see those files aren't there anymore.

[1:07] Go ahead and add all of them, git commit -m finished bot, and let's go ahead and push. After a quick refresh, we can see that our bot is here, and all of the files are there.

[1:27] Let's head over to railway.app to deploy our bot. This is an app I've used multiple times for deploying bots. It's fairly simple to set up. You'll create an account. We'll head over to Start a New Project, Deploy from GitHub.

[1:47] If you don't have an account, or you just created one, you're going to need to configure your GitHub application so that it has access to your repository. We'll do the-best-book-club-bot, hit enter.

[1:59] Then, we're going to need to add in a couple of variables. These variables are going to be what we put in our env file. The first thing we're going to need is the token. Paste that in, add. We're going to need our client ID.

[2:19] The last thing will be our Guild ID. Now, if we head over to our deployments, we'll see that it's already deployed for us after we added our environmental variables.

[2:37] We'll click on this, and we can see we're logged in. We'll head over to our Discord application. We can see it's still running. Let's give it one quick test, hit enter. Everything is running as expected.

[2:58] One last thing about the Railway app is it does have a starter plan for you. It gives you a lot of free hours that restart each month, but it will not last you the entire month.

[3:09] If you don't want to end up paying, you can use somewhere else, but I personally like to use the Railway app.

egghead
egghead
~ 3 minutes ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today