Building a Discord Bot with Python - Bot Basics

Published: 01 March 2021
on channel: Jonah Lawrence • Dev Pro Tips
5k
75

How to make a Basic Discord Bot with Python

Subscribe:

In this tutorial, I will be showing you how to get started with building bots for Discord. You will learn how to create a bot user for running a bot, how to install the necessary libraries, and write a bot that can respond to messages and commands.

‍ Source Code


Dev Pro Tips Discussion & Support Server


Discord.py (dpy is no longer maintained, see Nextcord below)
Documentation - h̶t̶t̶p̶s̶:̶/̶/̶d̶i̶s̶c̶o̶r̶d̶p̶y̶.̶r̶e̶a̶d̶t̶h̶e̶d̶o̶c̶s̶.̶i̶o̶/̶e̶n̶/̶l̶a̶t̶e̶s̶t̶/̶i̶n̶d̶e̶x̶.̶h̶t̶m̶l̶
Discord.py Server -

Nextcord
Documentation -
Nextcord Server -

Python-dotenv Documentation


Python Discord Bot Template


Note:
- At 8:30, the package you should install is "python-dotenv" instead of "dotenv-python."
- At 9:30, "ctx" is used as a parameter when this is really a Message object and not Context. To make it more clear, I have renamed the variable to "message" in the GitHub repo. In any case, using commands is a better practice and don't use on_message at the same time as commands since they conflict.

In future videos in this series, I will show you how you can:
* Host your bot for free online 24/7
* Build cog modules to help make your code more maintainable
* Implement a fancy Help Command
* Interact with other APIs to make useful bot features
* Much more

Make sure to subscribe so you don't miss anything!

In this video:
0:00​ - Introduction
0:14 - Making a GitHub repo
1:25 - Creating the main bot structure
2:08 - Installing Discord.py
3:05 - Creating a bot user
4:17 - Creating and loading environment variables
5:48 - Creating a bot in Python
8:10 - Loading more environment variables
9:20 - Listening for messages
10:34 - Adding the bot to a Discord server
12:40 - Debugging in Visual Studio Code
14:20 - Making a ping command
16:13 - Adding command documentation
17:03 - What's Next
17:28 - Conclusion

More Discord Bot Tutorials


More tutorials


‍️ Find me on other channels
Discord ️
Twitter
Github ‍
Sponsor
Buy me a coffee

SPONSORS
Get your username or a link to your channel here by sponsoring on GitHub


GET FREE STUFF WHILE SUPPORTING MY TUTORIALS


Watch video Building a Discord Bot with Python - Bot Basics online without registration, duration 17 minute 54 second in high hd quality. This video was added by user Jonah Lawrence • Dev Pro Tips 01 March 2021, don't forget to share it with your friends and acquaintances, it has been viewed on our site 5 thousand once and liked it 7 people.