Deploy your Discord bot on Heroku

“Readying the felines.”

We live in a digital age. Online services like Netflix and multiplayer games are made possible through Web Application. The application is deployed and run on a server. The client (User) requests a specific service from the host. The host in accordance with the request runs the specific application the user requires. The applications are hosted and deployed on a web server. In this tutorial, we deploy a simple discord Application (A bot) on Heroku.

Structure :

    1. What are Discord, Heroku, and GitHub?

    2. Make your Discord Application

    3. Deploy your bot

    4. Next steps


1. (a) Discord

Discord is a popular group-chatting application. It was originally made to give gamers a place to build communities and talk. But since its launch in 2015, it has branched out to include communities from all over the internet, ranging from writers to artists to K-Pop stans. Discord is available and ready to use on Windows, Mac, Linux, and Android platforms. Alternatively, Discord can be run on a decent browser like Mozilla Firefox.

1. (b) Heroku

Heroku is a cloud platform that lets companies build, deliver, monitor, and scale apps. It is the fastest way to go from idea to URL, bypassing all the infrastructure headaches. In cloud technology, we call this type of service PaaS (Platform as a Service). Heroku is used for the rapid deployment of applications. It also provides a URL for the application.

1. (c) GitHub

GitHub, Inc. is an American multinational corporation that provides hosting for software development and version control using Git. It offers the distributed version control and source code management (SCM) functionality of Git, plus its own features. It provides access control and several collaboration features such as bug tracking, feature requests, task management, and wikis for every project. Headquartered in California, it has been a subsidiary of Microsoft since 2018.

2. Make your Discord Application

Source code of the bot :

import discord
from discord.ext import commands

async def on_ready():
print("Bot is ready")

async def on_member_join(member):
print("A wild",member,"appeared")

async def on_member_remove(member):
print("The wild",member,"disappeared")

async def ping(ctx):
await ctx.send(f"Hey! I am up and running with a ping of {round(client.latency*1000)}ms.")

client.run('') #Place token between the ''


i) Register for a new account if you don’t own a registered Discord account yet here.

ii) Visit the Discord developer portal. Log in with your credentials if prompted.


iii) Click on the “New Application” tab. Enter your desired name of the application.


iv) Select your desired picture for the application. Copy the client ID and secret token to a text editor and save it.


v) Go to the “Bot” section in the left-hand list. Select “Add bot”.


vi) Copy the bot’s secret token in the same text editor as before.


vii) Go to the “OAuth2” section in the left-hand list. Check “bot” under the “SCOPES” section. Copy the URL generated below the same section.


With all this done, simply paste the generated HTTP link into a browser and open it to invite your bot to your choice of server. Now, we deploy the bot on Heroku as guided hereon.

3. Deploy your bot

i) Register for a free Heroku account here.

ii) Login using your credentials if prompted. Navigate to “New”>Create New App.


iii) Choose a unique application name and choose either the United States or Europe for the region.

iv) Choose GitHub as your deployment method. Link your GitHub to Heroku following on-screen instructions. Follow this tutorial if you’re new to GitHub to make your own repository. https://guides.github.com/activities/hello-world/


v) Go to https://github.com/kum4r2k/botpy. Click on “Fork” on the top right side. Browse to your forked repository.


vi) Edit the bot.py file in your repository to paste your bot token we saved earlier at the end of the file.


vii) Browse to settings and make sure Repository visibility us Private. Link this repository to Heroku in the deployment section.

viii) Scroll down to Manual Deploy and deploy your bot. Now if you check your Discord server the bot should be online. This is a simple bot for demonstration all it does is check ping using the “!ping” command.

4. Next steps

This is a very simple bot. The purpose of this bot was to demonstrate deployment on Heroku. There are some great discord bots available on GitHub which I’ll be lining down below. You can deploy those bots in a similar fashion for all your needs on Discord.

  1. https://github.com/SamArroyos22/BasicDiscord-Bot
  2. https://github.com/python-discord/seasonalbot
  3. https://github.com/Rapptz/RoboDanny

Comments are always welcomed if you come across a hurdle or you wish to learn more.

(Visited 1,513 times, 1 visits today)
September 14, 2020

0 responses on "Deploy your Discord bot on Heroku"

    Leave a Message

    Your email address will not be published. Required fields are marked *