What is Discord?

Discord is a popular chat platform that allows people to join servers that align with their interests. I use Discord to stay in contact with my friends that play Pokémon, both Pokémon Go and the mainline series. Discord comes with some built-in features, but the application becomes more powerful when you add bots to your servers. There are thousands of Discord bots that do everything from moderate the server to post game scores. I’ve wanted to develop a Discord bot for a while, but I wasn’t sure where to start. A quick Google search brought me to the RealPtyhon tutorial.

The RealPython Tutorial

RealPython is an excellent website that provides resources for Python developers. To learn how to build my bot, I used this tutorial from RealPython. In about three hours, I ran through the tutorial and received a jump start on developing a bot of my own.

What is covered?

The tutorial starts with definitions, ensuring that readers know important terms like Discord and bot. After covering the basics, the tutorial teaches the reader how to create a Discord Developer account. The instructions are detailed, so you cannot miss any critical steps. I advise you to build a basic bot while working alongside this tutorial, so you don’t miss any steps.

The tutorial recommends creating a test server. Once you’ve established your developer account and your test server, you’ll connect your bot to the server using OAUTH2. By following along with the tutorial, I connected a bot to my test server.

After teaching you how to attach your bot account to your test server, the tutorial explains how to code the application in Python. First, they teach you how to install the discord.py library and establish a connection to the bot user. This step involves passing your Discord Token into your program, so you get a secure and stable connection.

The tutorial covers events and commands, which are the two ways you can interact with a discord bot. Events are things that could happen on the server. The discord.py library contains many different possible events. RealPython’s tutorial starts by showing you the “on-ready” event, which is triggered when the bot connects to Discord. Other events covered include “on_message” and “on_member_join.” The tutorial covers the common event triggers, which makes it easy to get started on your first bot. Finally, potential errors are covered so you don’t accidentally create an infinite loop error.

Commands are another way to interact with a discord bot. Commands start with a prefix(usually a question mark or exclamation mark), making it difficult to trigger the bot by accident. The RealPython tutorial does a great job of teaching you how to create a command prefix and then build commands from there. They give several examples so you can imagine possibilities for your future projects.

Once you’ve created commands, you might want to restrict access to those commands to specific users. Commands are restricted using checks. Checks can prevent commands from running, so admins can have exclusive access to certain commands. RealPython’s guide covers creating these checks. By following their instructions, I was able to create admin-exclusive commands, which are ideal for keeping your bot running properly, without having to edit the code itself.

Knowing how to connect the bot, create events, create commands, and restrict access to specific commands is vital to building and maintaining a discord bot. If you have a basic knowledge of Python and follow this tutorial, then you are well on your way to create your Discord bot. By following the Discord, I was able to build my first Discord bot. Overall, this tutorial is a wonderful resource for people that are learning the basics of Discord chatbot creation. Discord has seen tremendous growth as a platform in the last year, so if you’re interested in chatbots, then you certainly should consider going through this tutorial and building your Discord Bot.

Once you’ve built your Discord bot, you’ll need other resources to expand the features. RealPython does not cover every aspect of Discord.py, so you’ll want to read the documentation and refer back to it as you have questions. Additionally, if you encounter a problem, you can always check out Stack Overflow to see if other people have had a similar issue. I found this tutorial to be a great starting point, but after a while, I began relying on the documentation and the experiences of others to help me build my bots.