Creating a Discord Bot With Python

Alan Constantino
6 min readFeb 2, 2020

If you’ve found this article useful, consider donating.

In this article, we’ll create a Discord bot using Python. The bot we’ll be creating today will have a simple purpose, telling jokes. We will give the bot a command and it will return a random joke. This should be simple enough, let’s get started!

Before Starting

I think it’ll be useful to understand what an API is before we actually get started. API stands for Application Programming Interface. Simply put, an API is what allows programs or services to communicate with other programs or services.

A great metaphor I came across (don’t remember the original source) was thinking of an API as a waiter at a restaurant.

So you, the customer, talk to a waiter to get your food. The waiter then talks to the chef who actually makes your food. The chef gives the food to the waiter. Finally, the waiter then gives the food to you.

Unpacking this metaphor, the user (customer) sends a request to an API (waiter). The API (waiter) then talks to the service you want to reach, usually a database (chef). That database (chef) then sends data (food) back to the API (waiter). And finally, the API (waiter) then gives you back data (food).

Great! Now that we know what an API is and have a general understanding of how it works, we can now move on to using one.

Acquiring the Jokes

--

--