Creating Cogs and Commands - Python Discord Bot

Creating Cogs and Commands - Python Discord Bot

Jonah Lawrence • Dev Pro Tips

3 года назад

10,584 Просмотров

How to add cog modules and more commands to a Python Discord Bot

❤ Subscribe: http://bit.ly/SubscribeDPT

In this tutorial, I will be showing you how to create cogs in a Discord bot to make maintainable and scalable code and I will also show you how to make more advanced commands that take multiple or unlimited parameters.

The commands I will be showing you how to make in this video are a dice rolling command and a command to pick a random choice from a list of options.

👨‍💻 Source Code
https://github.com/DenverCoder1/Tutorial-Discord-Bot/tree/part-3-cogs-and-commands

💬 Dev Pro Tips Discussion & Support Server
https://discord.gg/fPrdqh3Zfu

📜 Discord.py (dpy is no longer maintained, see Nextcord below)
Documentation - https://discordpy.readthedocs.io/en/latest/index.html
Discord.py Server - https://discord.gg/r3sSKJJ

📜 Nextcord
Documentation - https://nextcord.readthedocs.io/en/latest
Nextcord Server - https://discord.gg/ZebatWssCB

📓 Python Discord Bot Template
https://github.com/DenverCoder1/discord-bot-template

📺 In this video:
0:00​ - Introduction
0:15 - Creating a Cog
3:06 - Adding Commands to a Cog
4:00 - Loading Cogs
6:30 - Adding a "Random" Cog
7:29 - Dice Roll Command
14:34 - Random Choice Command
18:35 - Conclusion

In future videos in this series, I will show you how you can:
* Implement a fancy Help Command
* Make a bot to welcome users
* Interact with other APIs to make useful bot features
* Much more

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

🐍 More Discord Bot Tutorials
https://youtube.com/playlist?list=PL9YUC9AZJGFG6larkQJYio_f0V-O1NRjy

💻 More tutorials
https://www.youtube.com/playlist?list=PL9YUC9AZJGFHTUP3vzq4UfQ76ScBnOi-9

🙋‍♂️ Find me on other channels
Discord 🗨️ https://bit.ly/dpt-discord
Twitter ✍ https://twitter.com/DenverCoder1
Github 👨‍💻 https://github.com/DenverCoder1
Sponsor 💞 https://github.com/sponsors/DenverCoder1
Buy me a coffee ☕ https://ko-fi.com/jlawrence

💖 SPONSORS 💖
Get your username or a link to your channel here by sponsoring on GitHub
https://github.com/sponsors/DenverCoder1​

🎁 GET FREE STUFF WHILE SUPPORTING MY TUTORIALS
https://bit.ly/jlawrencepromos

Тэги:

#how_to_make_a_discord_bot #discord_bot #discord_bot_tutorial #discord_bot_in_python #discord.py_tutorial #how_to_make_a_bot_with_discord.py #python_tutorial #discord.py #how_to_make_a_bot #discord_developer #discord_bots #programming #programming_tutorial #how_to_make_a_discord_bot_with_python #how_to_make_a_discord_bot_in_python #make_your_own_discord_bot #discord.py_rewrite_tutorial #python_discord #cogs #adding_cogs_to_discord_bots #adding_cogs_python_discord_bot #bot_modules
Ссылки и html тэги не поддерживаются


Комментарии:

tienzo
tienzo - 23.12.2022 19:31

In the same file, can I put multiple commands inside 1 single class, something like Class Moderation() and inside moderation commands like ban, unban, mute etc?
Or should it be 1 command per class in the same file?

Ответить
Phobit
Phobit - 30.08.2022 15:14

What exactly is the point of splitting cogs into different files? Is it only for better reading/structure? Why shouldn‘t I just put all my commands into one big cog alongside with the events (on_ready, on_message, etc alongside the commands.Cog.listener decorator)?

What are good criteria to split which commands go into one cog and which need a seperate cog file?

Ответить
Otto Wagner
Otto Wagner - 02.03.2022 20:48

Which VS-code theme are you using?

Ответить
Unknown Engineer
Unknown Engineer - 29.11.2021 19:52

Can you continue this series. I’m really loving it

Ответить
Fahim Miah
Fahim Miah - 12.03.2021 09:26

How can I use cogs with Json? I am having a hard time connecting the two files. Both files ARE in the SAME folder.

Ответить