Python is a programming language that strives for readable code above all else. You’ll find that Python has plenty of white space — which in turn makes it easier to read and write.

Getting Python for Discord Bot Development

The best place to get a hold of Python is on the official website:

If you’ve never installed Python before and are looking for a great step by step guide to do so, then I’d recommend taking a look at this guide from RealPython.

They wrote an awesome guide that shows you how to get Python set up and configured on Windows, Linux, macOS / Mac OS X, iOS, and Android!

So go get it downloaded, follow the installation guide, and you’ll be ready for the next step — setting up the library.

Setting Up and Using the Library

Like we mentioned earlier, you should be using a library whenever possible to avoid writing tedious low-level code around the Discord API.

The best library to use for Python is, available on GitHub.

Luckily, has very thorough documentation on its wiki — you should be able to find all of the answers you need, both in getting it set up for your project and examples of how you’d start coding a simple Discord bot.

Installation Help:

To set up on your machine, you can follow the step by step process detailed here on the official wiki.

That guide walks you through the process of setting up, getting it running, explaining how events work, and much more…

Discord Bot Creation GIF 2

Making a Very Simple Discord Bot in Python

The documentation library has a great tutorial on making a quick bot in Python in as little as a few minutes!

You can find the full tutorial to a simple bot over at this link.

I’d recommend going through that link, reading through the “Minimal Bot” section, and then looking at the step by step walkthrough that explains exactly what’s going on in the code.

Here’s the code you’ll be using to create your first minimal Python Discord bot:

import discord

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!')'your token here')

Here’s what this code does:

Once the bot is logged in and ready, it’ll show a message on the Python console you ran your bot from: “We have logged in as {bot username}”. 

Whenever a message is received (in the same Discord channel your bot is in) from someone else (other than the bot itself, we don’t want the bot to respond to its own messages!), if that message starts with “$hello” then the bot responds back to the channel saying, “Hello!” 

Very simple, but also a very good start in Python bot development if you’re a beginner!

Adding Your Python Bot to a Server

To connect to your bot and add it into your Discord server, you’ll need to create an Application in Discord and then get your own Discord Bot Token assigned to you. 

Notice in the code above your bot actually runs with the last line of code: “‘your token here’)”. 

You’ll have to replace ‘your token here’ with your bot’s token.

Here’s a detailed guide to getting your own bot token and adding your bot to your server.

Your Next Steps in Python Bot Development

Now that you know how to make an extremely simple Discord bot in Python, it’s time to step it up a notch. 

Scroll down to the “Discord Bot Ideas” section in this guide and come up with a few bots you think you’d enjoy creating. 

After you come up with your list, I’d recommend browsing around on GitHub (filter by programming language: Python) and typing your bot ideas in to see if anyone has created anything similar. 

Pay attention to how they laid out their bot, how they laid out their code, if they have any comments in their code to make reading it easier, etc. 

Looking at and analyzing other people’s code can be a great way to uncover certain bits and pieces of your idea that you hadn’t thought of yet. 

After you have your idea and a good sense of how other similar bots look, it’s time to get into the grind and start coding. 

If you want to learn how to create Discord bots step by step and dive into more advanced topics, join the WriteBots community. We’ll send you tips, tricks, code samples, lessons, ideas, and more. It’s the perfect opportunity for you to learn more and level up your bot creation skills.

Leave a Reply