Building a Discord Chatbot with Python (5) - Adding a 'Fortune Telling' Feature
In this article, we’ll expand our chatbot by enabling it to respond to user messages.
We’ll also introduce a fun ‘Fortune Telling’ feature to our chatbot.
A Recap of Our Progress
As of our previous session, our chatbot can now receive user messages in a chat.
Here’s what our chatbot.py
script currently looks like:
Building a Discord Chatbot with Python (4) - Receiving Messages with Your Chatbot
In this article, we’ll finally dive into creating a chatbot in Python.
Firstly, ensure that your working directory, discord-chatbot
, contains at least the following two components from our previous sessions:
.venv
directory: This is for a virtual environment.
.discord_token
file: This file contains a Discord token.
1. Activating the Virtual Environment
-
Move to the
discord-chatbot
directory and activate the virtual environment:
Building a Discord Chatbot with Python (3) - Adding Your Bot to Discord
In this article, we’ll walk through the Discord settings for your chatbot.
1. Create a Discord Account
If you don’t already have a Discord account, start by creating one.
For a guide on account creation, check out this link.
2. Create a Discord Server
Next, set up the Discord server where your chatbot will operate.
-
Click the ‘+’ icon in the top-left corner.
-
Choose “Create My Own”.
-
Select “For me and my friends”.
Building a Discord Chatbot with Python (2) - Setting Up the Development Environment
In this article, we’ll prepare the development environment to build a Discord chatbot in Python.
We’ll be utilizing the discord.py library.
Ensure you have Python version 3.8 or higher to use this library.
1. Create a Working Directory
Let’s begin by creating a working directory named discord-chatbot
.
All our operations will be performed within this directory.
Building a Discord Chatbot with Python (1) - An Introduction
In this guide, we’ll create a “chatbot”, a program that automatically responds to messages in a chat using Python.
Developing a chatbot is a rewarding next step for beginners who have just completed their basic tutorials or courses.
Over the course of several articles, we’ll add various features to our chatbot, making it more versatile and interactive.
Goals of This Series
Throughout this series, we aim to add the following functions to our chatbot: