Create your Own Discord Bot in 4 lines of Code (Python)

ip Finder
2 min readMay 22, 2021

This Bot will be made in python so make sure you have python installed. you can install python here.

Open command prompt and type the following :

pip install discord-bot-maker

This will install the required modules.

Go to Discord Developer Portal and create an application by clicking on “New Application” and then follow the steps given here.

Copy the TOKEN and save it somewhere. We will need it later in this tutorial.

Open a text editor of your choice(or open IDLE if you are a beginner)

We will now start writing the code for our bot

  1. Import the required module
from discord_bot_maker import DBot

2. Create an instance of the DBot object which allows us to create commands that our bot can respond to

d = DBot("PREFIX", "TOKEN")

Replace PREFIX with a prefix of your choice (for example: .) and TOKEN with the TOKEN that we saved before.

NOTE : The bot responds to commands that follow the prefix(for example: .hi runs the command “hi” only when it is preceded by the prefix).

3. Create your command using the arguments provided.

d.createCommand(trigger = "sup", reply = "I am fine", reply2 = "What about you?", emoji = "😄", image = "sup.gif", help = "replies with 'I am fine'")

trigger is the message that triggers this command(.sup)

reply specifies the message that our bot sends in response to the command. Here, “I am fine” is sent.

reply2, emoji, image and help are optional arguments that you can provide.

4. Run the bot

d.bRun()

Here is the entire code:

from discord_bot_maker import DBot

d = DBot("PREFIX", "TOKEN")

d.createCommand(trigger = "sup", reply = "I am fine", reply2 = "What about you?", emoji = "😄", image = "sup.gif", help = "replies with 'I am fine'")

d.bRun()

Congratulations!

You just made a discord bot in 4 lines of code!

Run the code and have fun with your bot. 😄

You can find more information about this module on pypi.

Join the discord server here

--

--