Article
10 Min

How To Make a Discord Bot

Learn to create and add Discord bots with this step-by-step guide to making, adding, and customizing bots to boost engagement and server functionality.

How To Make a Discord Bot
Listen to the audio version
13:47
/
19:15
1x

Discord bills itself as “where the world talks, hangs out, and builds relationships with their communities and friends.” What started out as a user-friendly VoIP (voice over internet protocol) and instant messaging platform for gamers quickly evolved into the perfect place to host an online community for businesses and hobbyists alike.

If you’ve ever joined or run a Discord server, chances are you’re familiar with Discord bots, those helpful autonomous agents or chatbots that can do things like:

  • Welcome new members
  • Moderate communities
  • Set reminders
  • Perform polls
  • Measure statistics and produce reports on demand

Discord bots have become a key differentiator for the platform, allowing community owners to take engagement, moderation, and interactivity within their communities to the next level.

Are you eager to harness the power of Discord bots for your own community? In this article, we’ll walk you through the steps needed to create your own Discord bot.

Different types of Discord bots

While you can manage Discord channels and servers manually, bots can help boost engagement and increase your productivity by performing a variety of tasks automatically. Here are some cool ideas for Discord bots you can make and add to a server.

  • Translation bot. This type of bot can help you translate different languages. It can be incredibly useful when dealing with a community of bot users from across the globe.
  • Moderation bot. With this bot, you can monitor all communication happening in a channel and delete messages that violate certain terms.
  • Statistics bot. This bot can help analyze data on a Discord server, allowing you to gain crucial insight into key metrics.
  • Voice command bot. This bot allows you to perform certain functions on a server using Discord bots.
  • Music bot. As the name suggests, this type of bot can play music on a Discord channel automatically.

Creating a Discord bot

From setting up a Discord account to setting permissions and adding the bot to a Discord server, here are steps for creating a custom Discord bot.

1. Create a Discord account and server

You can’t create a Discord bot without having an account and setting up your own server. Go to Discord.com and create one with your email address and date of birth.

Once you’ve created a Discord account, proceed and log in. You will be directed to the following page.

Create a Discord Account and Server

To create a server, click on the Add a Server button, which is highlighted below.

Click on the Add a Server Button

Pressing the Add a Server button directs you to a pop-up screen—with options to either create a custom server or select one from templates like gaming, school club, and study group.

Create Your Server

In this example, we will be creating a custom server, so go ahead and click on the Create My Own button.

You will be directed to another pop-up window where you have to choose whether the server is just for a few friends or a bigger community.

Tell Us More About Your Server

In our case, we will select the For a club or community option.

Once you’ve made a selection, you’re directed to the following pop-up window—where you can add your server’s name and image icon. Proceed to add your server details and click the Create button. Note the image icon is optional.

Customize Your Server

And with that, you’ve created a Discord server. You can invite friends to join the server, as well as personalize it further by adding channels and an icon.

You've Created a Discord Server!

2. Click “Applications”

In the previous step, we set up a Discord account and created a custom server. Now, we can dive into the fun stuff—creating a Discord bot.

Start by navigating to the Discord developer portal in your browser and selecting the Applications tab. You can also manually search the portal by typing “Discord developer portal” in your search engine.

Click Applications Button

3. Name your application

Click on the New Application button and add a name for your Discord application in the pop-up window. Finally, accept Discord’s terms and conditions—and press the Create button to add the bot.

Name Your Application

4. Select “Bot”

Once you’ve named the bot, you are directed to the following page containing general information about the bot and other settings.

Select Bot

Navigate to the Bot tab on the page to access the authorization flow settings and privilege gateway intents.

Navigate to the Bot Tab

It’s a good idea to make sure Public Bot under the Authorization Flow section is switched on if you want public users to be able to invite your bot to their servers. The Requires OAuth2 Code Grant is switched off unless the service you are developing requires it.

Authorization Flow

5. Copy the bot’s token

The bot’s client ID and Discord API token will be displayed as soon as you create it. Be sure to copy the token, as it can only be viewed once when generated. If you forget or lose access to your token, you will need to regenerate a new one.

You can find your bot’s token in the red, blurred-out section.

Copy the Bot's Token

6. Navigate to the OAuth2 URL Generator tab

The next step is to add the scopes and bot permissions. First, select the OAuth2 tab and navigate to the OAuth2URL Generator section.

Navigate to the OAuth2 URL Generator tab

7. Tick the “bot” checkbox under “scopes”

Find the bot checkbox and ensure that it's checked.

Tick the Bot Checkbox Under Scopes

8. Set bot permissions and copy the generated URL

Scroll to the bottom to tick the permissions required for your bot to function. You can also grant all permissions by checking the Administrator checkbox—but you have to be careful since it could lead to security vulnerabilities.

Set Bot Permissions

The invite URL will be autogenerated depending on the permissions you select. Currently, our link appears as shown below.

Autogenerated URL

If the Bot URL is not autogenerating, return to the Authorization Flow section of the Bot tab and make sure that Requires OAuth2 Code Grant is switched off.

Authorization Flow

9. Paste the bot’s URL into a browser and invite it to your server

In step one, we created a custom server. We can now add the bot to the server by navigating to the URL generated in the above step.

If you have multiple servers, they will appear in the dropdown window. In our case, we are adding the bot to the Example server.

Once you choose a server, click the Continue button to proceed.

Invite the bot to your server

You will be given an opportunity to confirm the permissions you previously selected. If everything looks good, click Authorize.

Also, you may have to confirm you’re a human to finalize the process.

Permissions Confirmation

Congratulations! You have successfully created a bot and added it to your server.

Popular Discord bots

Whether it's welcoming new users, replying to certain messages, providing general information about the server, or banning individuals violating certain terms, bots bring powerful functionality to Discord. Here are popular examples of Discord bots.

  • ProBot. This bot lets you welcome new members, react to messages, assign roles to users, and reward the most active users. ProBot can also be used for moderation, including detecting offensive messages and banning users.
  • Helper.gg. This bot helps businesses manage tickets, create staff accounts, and control their permissions. It's also capable of automatic language translation, enabling organizations to target audiences in different regions.
  • Dank Memer. It helps you boost your community’s engagement by generating and posting memes on various servers.
  • Arcane. If leveling and community roles are vital to your channel, Arcane is the general-purpose Discord server management bot that meets your needs.  
  • Community Hubs. This bot allows members to post content in specific channels or hubs, making it easy for other users to find whatever they’re looking for.
  • MEE6. This organization provides the gold standard for Discord server management bots. It welcomes new users, enforces server rules, and adds levels, XP, and roles.
  • Midjourney. This bot enables users to generate images using Midjourney’s text-to-image AI from within the Discord environment. However, free users can have a limit on the number of images they can generate.

How to add bots to Discord servers

Adding bots to Discord servers typically follows the same process. You have to invite the bot to your server, set permissions, and provide necessary authorization. We’ll demonstrate how this process works by adding the Dank Memer bot to a Discord server.

Navigate to the Dank Memer website

In your browser, navigate to the Dank Memer website, which is shown below.

Navigate to the Dank Memer website

Click on the Invite Now button to invite the bot to your Discord server.

Invite the bot to your server

Invite the Discord bot to the server

Clicking on the Invite Now button will direct you to the following page, where you will select the server to which you wish to add the Dank Memer bot.

Invite the Discord Bot to the Server

Press on the Select a server dropdown button and choose your desired Discord server, as demonstrated below. In this case, we will be adding the bot to the Example server.

Press on the Select a Server Dropdown Button

After selecting a server, click on the Continue button to proceed.

Grant necessary permissions

Clicking on the Continue button will direct you to the following page, where you will have to grant permissions to the bot.

Grant Necessary Permissions

In this case, the Dank Memer bot requires the checked permissions to work. This requirement means that revoking some of the permissions may cause the bot not to function as expected.

Leave the default permissions as they are and scroll down the page. Click on the Authorize button—at the bottom of the page—to complete the authorization process.

Click on the Authorize Button

Check the Discord server

Now that we have invited the Dank Memer bot to our server, let’s check if the integration was successful.

Open the Discord application and then navigate to the server where you added the Dank Memer bot. You should see the following page if the bot was added successfully.

Check the Discord Server

You can use different commands to interact with the Dank Memer bot. For instance, the /clap command allows the bot to add “clapping hands” emojis to your message.

Discord Clap Command

Different ways to develop Discord bots

You can add many third-party bots to your Discord server. But if you want extra features and more control over what the bot does, consider developing a custom bot from scratch. Programming languages like JavaScript, Python, and C++ have numerous built-in libraries you can use to create and configure Discord bots. At the same time, an NPM (a software package manager and registry for JavaScript) can give you access to additional code libraries.

Read on to learn how to build a Discord bot using Python.

Developing a Discord bot using Python

Python is a powerful language with a wide variety of open-source dependencies you can use to create Discord bots, such as discord.py. To illustrate, we will create a simple bot that can reply to limited user messages.

Install Discord library

Start by installing the discord.py (Python) library on your computer using the following command.

--CODE language-markup--
pip install discord.py

Create a new project

On your desktop, create a new folder and give it a name. Inside the folder, add two new files: main.py and artbot.py.

Create a New Discord Project

Add logic to the artbot.py file

Open the artbot.py file in your code editor. This file will contain all the bot’s logic.

Start by importing the Discord library at the top of the file using the following line of code.

--CODE language-markup--
Import discord

Next, let’s add a function that will store the bot’s feedback. In this simple example, the bot will only be replying “Hi there” or “Hello user. Welcome” to user inputs. So, the function will look like this:

--CODE language-markup--
def handle_user_messages(msg) ->str: 
message = msg.lower() #Converts all inputs to lower case if(message == 'hi'): 
return 'Hi there' 
if(message ==’hello’): 
Return ‘Hello user. Welcome’

Next, we write the following function to handle communication between the user and the bot. This function checks the user’s input and sends a reply to a channel. It also handles errors that may occur when processing messages.

--CODE language-markup--
async def processMessage(message, user_message): 
try: 
botfeedback = handle_user_messages(user_message) 
await message.channel.send(botfeedback) 
except Exception as error: 
print(error)

Finally, we create the main (runBot) function to control our bot. The function contains your bot token, which is required for authorization. You can get a Discord token from your bot’s application page. It’s always a good idea to store the token in a separate .env file for privacy—but in this example, we’re aiming for simplicity.

The runBot function also has nested methods (on_ready and on_message) that are triggered when the bot is online and when a new message is detected.

--CODE language-markup--
def runBot(): 
discord_token = 'MTE0MjAyNTYyNDkzMjg0MzU5MA.GAvF0I.ZRAgSRHz6YlEaIek2y5dyvybJJTc7Jhr10hI2E' client = discord.Client(intents=discord.Intents.default())
@client.event 
async def on_ready(): 
print({client.user}, 'is live') 
@client.event 
async def on_message(message): 
if message.author == client.user: 
return 
await processMessage(message, 'hi') 
client.run(discord_token)

Add main method

We can add the main method required to execute the program in the main.py file, as follows.

--CODE language-markup--
import artbot 
if __name__ =='__main__': 
artbot.runBot()

‍Test

Now that we’ve created a bot, we can start it up and then add it to a server.

If you followed the above steps correctly, you should see the above outputs when you run your bot application.

The Artbot bot should also reply to messages in any server it’s added to. As shown below, the Artbot generates a new Discord message when the user types “hi” in a channel.

Discord Test

With this setup, the bot goes offline when you switch off your computer. For continued performance, consider saving the bot code on GitHub or hosting the application on a web server.

Overall, are Discord bots hard to make?

Generally, making Discord bots depends on your level of expertise, experience, and programming knowledge of languages like Python and C++. If you’re familiar with the Discord development environment and have some coding skills, even beginners can find making Discord bots relatively simple.

If you lack the necessary technical knowledge, you can still make Discord bots using third-party tools with drag-and-drop user interfaces. Numerous online tutorials and learning resources on platforms like Udemy can help you create a Discord bot.

FAQ Section

Creating a Discord bot can be both exciting and challenging. Below are some common questions related to developing Discord bots.

What skills are required to create a Discord bot?

Creating a Discord bot requires prerequisites, including knowledge of programming languages like Python or JavaScript. Familiarity with libraries such as discord.js or discord.py and frameworks like node.js is also important. A good programmer can help you navigate these tools effectively.

Can I develop a Discord bot for mobile platforms like Android?

Yes, you can develop Discord bots that interact with mobile platforms, including Android. However, the bot itself will run on a server or cloud service and communicate with users through the Discord app.

How can I ensure my Discord bot remains online?

To keep your Discord bot online, consider hosting it on a cloud platform or server. This type of bot management ensures continuous operation despite environmental variables you can’t account for. Additionally, setting up notifications can help you monitor the bot’s status and address any downtime quickly.

Are there prebuilt libraries to help with Discord bot development?

Yes. Several prebuilt libraries like discord.js and discord.py simplify the process of creating a Discord bot and assist with implementation. These libraries provide the necessary tools to interact with the Discord API.

Hire a bot developer for the best results

In this article, we covered how to make a Discord bot, along with some of the more popular Discord bots already out there. While creating a simple Discord bot is relatively easy, building something custom that’s as powerful as some of the more popular bots available to the public will require programming skills in languages like Python, the language used for coding Discord bots.

You can hire an experienced programmer on Upwork who is familiar with discord.js, discord.py, and other related technologies to create a custom Discord bot for your server. They can help you build, deploy, and maintain your bot effectively. Hire a bot developer on Upwork today.

If you’re a freelancer with Discord skills, look for bot developer jobs on Upwork.

Heading
asdassdsad
Projects related to this article:
No items found.

Author Spotlight

How To Make a Discord Bot
The Upwork Team

Upwork is the world’s work marketplace that connects businesses with independent talent from across the globe. We serve everyone from one-person startups to large, Fortune 100 enterprises with a powerful, trust-driven platform that enables companies and talent to work together in new ways that unlock their potential.

Latest articles

Popular articles

Join Upwork, where talent and opportunity connect.