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
Also published on Medium's gfrkad