How To Make A Discord Bot Using Python And Discord API

How To Make A Discord Bot

Discord is a lot more than just a social media app. Sometimes managing the application alone can be a tough job. It has got text, video, and audio servers all working at the same time. For the user’s ease Discord has introduced the concept of Bots. Well, here is an article that will tell you how to make a discord bot.

Bots are the AI (Artificial Intelligence) that help the user to manage the tasks going around in its discord account. There are various predefined bots in the discord applications such as the Moderation bots, translation bots, music bots, and many more. Other than this discord provides an opportunity for the programmers to create their discord bot. Here we are with an article that will guide you on how to make a discord bot.

Well, if you are looking for how to make a discord bot, then the first thing you need to do is to make a Discord Bot account. After you have created the bot account, you have to invite the bot to the server via the invite URL. After you are done with this process, you need to write the python code in the Discord API wrapper.

How To Install & Use Pro Bot on...
How To Install & Use Pro Bot on Discord - Tutorial

This guide on “How To Make Discord Bot” will explain to you every process mentioned above. 

How To Make A Discord Bot

Further in the article, you will find the step to step guide on “How to make discord bot”. We have mentioned the simplest method for the purpose and specialty of the article is that you don’t have to download the special Python IDE for creating the bot.

Also Read, How To Stream Netflix on Discord Without Black Screen!

How To Make A Discord Bot Account

How To Make A Discord bot Account
Source: Real Python

Before you start making your discord bot you must have a Bot account on the platform. After you have created a discord bot account, you can start working with the Discord API (Application Programming Interface) and Python Library.

Follow the steps given below to create a discord bot account.

  1. The first step would be to log in to the Discord Website.
  2. Next, Navigate to the “Application Page” and click on the “New Application” button.
  3. Now, the next page will ask you to create the application name. Name the application and click on “Create”.
  4. On the new desktop window, on the left window pane navigate for the option “Bot”. Click on it.
  5. And, then Add Bot On the right side of the window. 
  6. Confirm the action by clicking on “Yes, Do it”.
  7. Make sure that the check box against the Public Bot is marked and the check box against the Require OAuth2 Code Grant is Unmarked.
  8. Your Bot has been created.
  9. On the next screen, you will find an option to copy the token. This is the password to your bot account. 

Note: Do not share this password with anyone. If someone has access to your Bot account, then your discord account can be controlled by them.

You can regenerate your Discord bot password anytime.

Inviting The Bot To Join The Server

How To Make A Discord bot - Inviting The Bot To Join The Server
Source: Discord Bot Server Documentation

After you have created the Bot now you have to invite the bot to join the server. We will do it by creating an invite URL. Follow the steps given below for the purpose.

  1. Go to “OAuth2” and click on it.
  2. Now navigate to the “Bot” under the scopes section.
  3. Next, you need to select the permissions that you want your Bot to do. Be careful while assigning the permissions to the bot, especially the Administrator permissions.
  4. After that click on the “Copy” button that carries the URL on the top.
  5. Now, this is the URL we are going to use to invite the bot to join the server. 
  6. Paste this URL in your browser and choose the server you wish to invite the bot to.
  7. Click on “Authorize”

Note: You need to have the Manage Server Permissions to add the bot.

Also Read, How To Record Discord Audio Using The Third Party Softwares

How To Make Discord Bot By Coding In Discord.Py Library

Now that we have created the bot, we will be writing the code in the python. is an API wrapper for discord and it will be helping us in writing the Discord Bot code in Python.

How To Make Discord Bot Using Repl And Discod.Py

How To Make Discord Bot Using Repl And Discod
Source: Replit

You can use any python editor on your personal computer to write the python code for the bot. But, the best suggestion would be using the Repl. Repl is an online IDE that can be used directly on the browser to write the python codes for the Discord Bot.

To write the discord bot in the Repl. start by visiting the Repl Website. Create the new Repl and Select the language as python. Now you can write the codes for the Discord bots which are called the events.

How To Make Discord Bot That Responds To Events

The whole discord python bots revolve around the concept of events. Events are the things or queries that you listen to and then respond to. For example, you make a bot for the chat server and program it in the way that if it reads “hello” it will reply with “Hello, How are you?”. In the above event, reading “Hello” and responding is called a whole event.

Here is the code that will work in the order mentioned above.

import discord

import os

client = discord.Client()


async def on_ready():

    print(‘We have logged in as {0.user}’.format(client))


async def on_message(message):

    if == client.user:


    if message.content.startswith(‘$hello’):

        await‘Hello, How are you’)‘TOKEN’))

Also Read, How To Find Your Discord ID, Server ID, Message-ID In Simple Steps


Well, that was all about how to make a discord bot. If you are still facing trouble or have any queries regarding the article above. Don’t hesitate to ask us. Python is a powerful language and we can create a lot more than the text bots. So, if you want us to write more codes for different events then do write to us in the comments section.

Leave a Comment

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

Scroll to Top