EASY! Organize Your Messy Code Using COGS! (Ep. 13)

  Рет қаралды 13,980

sanamo

sanamo

Күн бұрын

About the Series:
Welcome to my "How to make a discord bot" discord.py bot development series. We will learn how to create a full featured discord bot utilizing the discord.py library. Hope you stick along!
About the Video:
In this discord.py bot development tutorial, you will learn how to utilize the Cogs feature of the discord.py library. By the end of this tutorial, you will have an understanding of how to use Cogs to better organize and lay out your code to prevent confusion for yourself or other readers.
Code in the Video:
github.com/sanamopy/discord.p...
Useful Links:
Python Documentation - docs.python.org/3/
Python Download - www.python.org/downloads/
Visual Studio Code Download - code.visualstudio.com/download
Discord.py Documentation - discordpy.readthedocs.io/en/s...
Discord Developer Portal - discordapp.com/developers
Repl.it - repl.it
Timestamps:
0:00 - Intro
1:45 - Setting up the Files
2:29 - Creating the Cog Class
4:40 - Adding a Slash Command
6:35 - Redefining Setup_Hook
12:06 - Adding the Setup Function
13:16 - Testing the Cogs
14:50 - Adding multiple Cogs
15:50 - Outro
About the Channel:
This channel is a personal profile for the KZfaqr, sanamo. He uploads content over a variety of different things. However, he tries to focus on development/programming. He loves to educate others in his journey of learning programming. He is a self-taught python programmer and is currently learning Java in an AP Computer Science class. If you enjoy his content, please don't forget to like and subscribe to him, it means a lot!
Other Recommended Videos/Playlists:
This is the playlist which includes all of my other Discord.py bot development tutorial videos. Check it out!
• Discord.py Ep. 1 - Set...
Check out the first video in this series to get started!
• Discord.py Ep. 1 - Set...
About our Products/Company:
Socials:
KZfaq: / @sanamopy
Discord: discord.io/sanamo
Twitter: / sanamoyt
Twitch: / sanamo
#discord #discordbot #discordserver

Пікірлер: 34
@thewonderwaffleofficial
@thewonderwaffleofficial 6 ай бұрын
Finally was able to get cogs working, thanks!
@andrewprince9349
@andrewprince9349 Жыл бұрын
After 3 days of looking this was the only I was able to find for making app commands work in cogs. THANK YOU SO MUCH! your a life saver! also amazing video keep up the good work! also, if I may suggest, don't say sorry when you have to clip the recording. for us its like .005 secs haha. anyway good job
@sanamopy
@sanamopy Жыл бұрын
Awesome, will take note. Glad you enjoyed it!! ❤️
@imthesrpina
@imthesrpina 10 ай бұрын
Gracias hermano, era lo único que me hacia falta y no sabia como añadir comandos slash usando cogs, me has salvado
@DarkDesiler
@DarkDesiler 8 ай бұрын
Thank you very much for this video man
@sanamopy
@sanamopy 7 ай бұрын
Glad it helped!
@zeneryx
@zeneryx 9 ай бұрын
i have been working for errors with cogs file for so long ong. thanks for the solution! you earned a sub from me :D
@sanamopy
@sanamopy 9 ай бұрын
Thank you so much! That means the world!
@hellrock
@hellrock 11 ай бұрын
Fellow 2-space indentation enjoyer :D
@axelb9131
@axelb9131 Жыл бұрын
Nice video ! If I had to say something tho, it would be to increase the zoom on the code for future videos :)
@sanamopy
@sanamopy 9 ай бұрын
Thank you for the tip! Hopefully the newer videos are better at that!
@colbysmith3149
@colbysmith3149 2 ай бұрын
Hey your channel has been the only helpful channel for the way I’ve set my bot up and over the last few days I e been rigorously attempting to figure out how to make my buttons only interact with individual users, for instance I want someone to be able to click the button and the view of that button to be disabled only for that interacted user, how can I achieve this by chance? I’ve tried making a view sub class etc just can’t figure it out. Thanks!
@disasterarea9341
@disasterarea9341 3 ай бұрын
"hopefully you know about classes before coming to this video" yeah no i have no idea what they are man. i just wanted to make a discord bot and i knew i didnt want 50 commands in 1 file but i didnt know how to go about it... looks like its a good thing im kinda starting here though, it would be a huge pain in the ass to write a lot of functioning code and then have to refactor it to fit in with this framework. what i dont get though, is you can put regular commands in other files and then import them in your main python file, but you cant do that with async commands without all this extra mumbo jumbo... any idea why it works that way?
@aaronrichardson3148
@aaronrichardson3148 4 ай бұрын
I can’t get my /cog1 to work and I’ve followed to a T. Any help? Any common errors I could work thru? I get no console errors, command doesn’t work
@12362736
@12362736 Жыл бұрын
👍👍👍👍👍👍👍👍
@sanamopy
@sanamopy Жыл бұрын
🙏
@officialdreamplayz
@officialdreamplayz Жыл бұрын
I have cogs and many folders inside it and then again cogs in it then folders then cogs then file and confused in loading and unloading them one by one i m fucked up but still trying to fix it hope everything works fine
@sanamopy
@sanamopy 9 ай бұрын
Oh yeah that sounds like a headache ngl. Just remember, each layer will be separated by the foldername and then a dot. If you need help, you can join my discord server, and I’d be happy to help. discord.gg/yhkADUBcRe
@zingthe64savage18
@zingthe64savage18 10 ай бұрын
can i use a method similar to this to load events into my bot?
@sanamopy
@sanamopy 9 ай бұрын
You could load separate cogs that only have events using @commands.Cog.listener() if that’s what you’re referring to.
@cameronedens9391
@cameronedens9391 7 ай бұрын
Does this code work with slash commands?
@sanamopy
@sanamopy 7 ай бұрын
Yes sir, it does!
@vihaan1
@vihaan1 9 ай бұрын
I did everything in the video but the cog is not loading and there are no errors
@sanamopy
@sanamopy 9 ай бұрын
Could you join the discord and send your code snippets, so I can possibly see?
@vihaan1
@vihaan1 9 ай бұрын
@@sanamopy Oh, sorry, it works now, I forgot to tell
@ttvReaper9064
@ttvReaper9064 Жыл бұрын
does this code still work?
@sanamopy
@sanamopy 9 ай бұрын
Sure does! Let me know any issues that you encounter.
@RoCodingYT
@RoCodingYT 24 күн бұрын
0/10, get straight to the point i just wasted 16 minutes for a simple thing to say
@sanamopy
@sanamopy 24 күн бұрын
Sorry you feel that way.
@kev4ik982
@kev4ik982 5 ай бұрын
How do we progress if we have to react on events, what should we change @client.event into then? @app_commands does not work here, as it does not have the attribute "event". And I also get the error "No module named 'cogs'" after finishing the setup_hook. What can be the issue? My folder is named "cogs".
Loading commands automatically from files with discord.py 2
6:19
Richard Schwabe
Рет қаралды 9 М.
Опасность фирменной зарядки Apple
00:57
SuperCrastan
Рет қаралды 11 МЛН
39kgのガリガリが踊る絵文字ダンス/39kg boney emoji dance#dance #ダンス #にんげんっていいな
00:16
💀Skeleton Ninja🥷【にんげんっていいなチャンネル】
Рет қаралды 8 МЛН
Discord.py Ep. 8 - Slash Commands
28:29
sanamo
Рет қаралды 18 М.
How to Make a Blackjack Game for Your Discord Bot
30:14
Ethical Programmer
Рет қаралды 171
Make a Discord Bot with Slash Commands
11:07
Ethan | The Code Syndicate
Рет қаралды 3 М.
FREE Discord Bot Hosting! 24/7 COMPLETELY FREE!
12:40
sanamo
Рет қаралды 15 М.
Discord PAGINATION: All You Need to Know
10:38
Richard Schwabe
Рет қаралды 12 М.
Rust Axum Production Coding (E01 - Rust Web App Production Coding)
3:53:02
My iPhone 15 pro max 😱🫣😂
0:21
Nadir Show
Рет қаралды 211 М.
Проверил, как вам?
0:58
Коннор
Рет қаралды 80 М.
8 Товаров с Алиэкспресс, о которых ты мог и не знать!
49:47
РасПаковка ДваПаковка
Рет қаралды 166 М.
Xiaomi SU-7 Max 2024 - Самый быстрый мобильник
32:11
Клубный сервис
Рет қаралды 527 М.