How To Host Your Own Discord Bot

If you want to host your own Discord bot to have full control over it, read on. Here's the guide on how host to your own Discord bot.

Discord’s most decisive advantage over any other online communication platform is the inclusion of bots. These bots are community-created and can be made to do anything. Primarily they’re used for automation to make the lives of server members easier.

Nowadays, you can access thousands of bots with a quick Google search.

Unfortunately, some bots out there go against Discord’s TOS/rules, so they quickly get shut down. Most bots that have YouTube playback support also got shut down by YouTube. The two most popular music bots, Groovy and Rythm, were also terminated.

Fortunately, that’s why we recommend hosting your own Discord bot. Then, you will have complete control over what happens to the bot, and no one will be able to tell you otherwise.

Here’s an extensive guide to hosting a Discord bot.

Table of ContentsShow

Do You Have A Bot?

Bot

First, to host a bot, you will need to have one ready. How complicated the creation process is will depend on what you want the bot to do.

You need some coding knowledge to create a working bot. However, there are a lot of online step-by-step guides that can help you with that.

There are also “free bot makers” like Bot Designer For Discord, Discord Bot Maker (on Steam), and Bot Ghost. But, we can’t confirm how well these bot creators really work.

Creating A Bot Token

Whether you have coded a bot or not, this is one necessary step. We need to grab a bot’s token, which will allow us to have control over it.

Here’s how you can do that:

  1. Head over to Discord’s Developer Portal.
  2. In the top-right corner of the website, click on New Application.
    Discord New Application
  3. Give this application a name for better management in the future.
  4. Once you create the application, you’ll be automatically redirected to a new page. Here, you’ll need to click on the tab labeled “Menu.” It should be right on your left.
    Discord Menu
  5. Click on Add Bot.
    Discord Add Bot
  6. Make sure the Public Bot option is enabled.

Okay, we now have a bot ready, so let’s see how you can invite it to your server.

Inviting The Bot To Your Server

On the bot’s page (you should be automatically directed after creating it), you will need the bot token.

To do that, click on Reset Token, copy it, and save it somewhere; we’ll need it later.

Discord Reset Token

Keep in mind that the token is basically the bot’s password, so keep this token safe and don’t send it to anyone. If you believe that the token has been compromised, you can always reset it again.

Now, expand the OAuth2 tab on the left-side menu and select URL Generator.

Discord OAuth2

Under Scopes, select bot and make sure everything else is left unchecked.

Choosing bot under Scopes on Discord permissions

For this next step, you will need to choose the bot’s permissions on your server. This is a crucial part of the process, and which permissions you need depends on what you plan this bot to do.

For example, if you want a music bot, it will need to Connect, Speak, Send And Read Messages, so check those permissions.

Discord Bot Permissions
 Some default permissions needed for most bots

For an auto-moderation bot, it will need to have access to a lot more permissions. But, the more permissions you give it, the more dangerous the bot can be if it gets into the wrong hands. So, make sure to leave the “Administrator” permission disabled if possible.

With that done, you can copy the generated URL at the bottom of the page and then paste it into your browser to invite it to your server.

Discord Bot Invite
Discord bot invite/Selecting server

By following these steps above, the bot should be a part of your server now.

Coding The Bot

This is the most challenging part of the process, creating/coding the bot. This guide does not focus on creating a bot, so we’ll use a basic code to start you out. For that, we’ll use Beau Carnes’ tutorial. You can rely on this guide if you want to go further into coding a Discord bot with Python.

Now, let’s get into it!

  1. We’ll need a code editor, but to keep things simple, we suggest you use Replit since it is browser-based.
  2. Creating an account on Replit (it should be straightforward.)
  3. We’ll need a development environment with Python. To do that, click Create, select Python under Official Languages, give it a name and click Create Repl.
    Replit Python
  4. Now, we’ll need to install the discord.py library. To do that, just click on Packages, type discord, and click install on the first result. (Note: the icon will be a + rather than a trash can)
    Python discord.py library
  5. With the library ready, go back to Files and add this basic code to make your bot respond to a specific message. Here’s the code:
1.	import discord
2.	import os
3.	 
4.	client = discord.Client()
5.	 
6.	@client.event
7.	async def on_ready():
8.	    print('We have logged in as {0.user}'.format(client))
9.	 
10.	@client.event
11.	async def on_message(message):
12.	    if message.author == client.user:
13.	        return
14.	 
15.	    if message.content.startswith('$hello'):
16.	        await message.channel.send('Hello!')
17.	 
18.	client.run(os.getenv('TOKEN'))

Now with the code ready, we’ll need to create a .env file in which we can add the previously obtained Discord bot token.

To create that file, click on Add File and type token.env.

Discord Bot env file

Now click on this newly created file and add:

TOKEN=[your bot token here]

With the token ready and the hello code added, click on the big green RUN button right on top of your code.

Discord Bot Run

Once you do this and you don’t get any errors, you’re successfully hosting your newly created bot to your Discord server.

To test whether the bot works, type $hello, and the bot should respond with a Hello! message.

How To Keep Your Bot Online 24/7

Replit, the online IDE, can work as a server for your bot, but only while it is running. The bot will go offline if you decide to close your browser or shut off your computer.

In other words, you have to keep Replit running 24/7 if you want the bot to be online all the time. So, if you have another computer, you can use it to run your bot.

However, this isn’t efficient, so you should consider using Discord bot hosting services.

Fortunately, there are tons of cheap options out there. Here are some suggestions: SparkedHost, SomethingHost, XGamingServer, and PloxHost. There are tons of other services available, but these are some of the most popular ones we managed to find.

Once you subscribe to their monthly services, you’ll just need to upload your bot. To access your bot files, go back to Replit, click on the three dots on the top-left of the page and select Download as zip.

Replit Download as zip

Conclusion

While we didn’t get into the nitty and gritty of creating a Discord bot since it requires extensive coding knowledge, this is an excellent foundation on which you can expand further.

If you’re willing, you could continue to learn more about coding in Python and build a proper Discord bot.

You might also find finished bots on GitHub or other similar open-source coding communities.

Related Reads

How To Lock A Discord Channel
How To Lock A Discord Channel
Branko Gapo

Keeping up with the incredibly fast evolution of computer technology is impossible. Branko aims to use his knowledge on this matter to share news and information on all the latest essential technological innovations and advancements.