Cogs problembs

Hi, do you mind is the problem here? I really don’t understand. What should I do? Some solutions?

main

import discord
import os
from discord.extimport commands

client = commands.Bot(command\_prefix='!')

@client.command()
async def load(ctx, extension):
client.load_extension(f'cogs.{extension}')
@client.command()
async def unload(ctx, extension):
client.unload_extension(f'cogs.{extension}')

for filenamein os.listdir('./cogs'):
if filename.endswith('.py'):
client.load_extension(f'cogs.{filename[:-3]}')


client.run('NTMyOTMxNDA2NDMxNTE4NzIw.XVmgxw.oajuqxlcbUCfVlRXY31XqArtFuQ')

 example

import discord
from discord.extimport commands

class Example(commands.Cog):

def \_\_init\_\_(self, client):
self.client = client

@commands.Cog.listener()
async def on_ready(self):
print("Bot is online.")

def setup(client):
client.add_cog(Example(client))

C:\Users\Dani\PycharmProjects\BotDiscord\venv\Scripts\python.exe -m Bot.main
Traceback (most recent call last):
File “D:\Users\Dani\AppData\Local\Programs\Python\Python37\lib\runpy.py”, line 193, in _run_module_as_main
“__main__”, mod_spec)
File “D:\Users\Dani\AppData\Local\Programs\Python\Python37\lib\runpy.py”, line 85, in _run_code
exec(code, run_globals)
File “C:\Users\Dani\PycharmProjects\BotDiscord\Bot\main.py”, line 15, in <module>
for filename in os.listdir(’./cogs’):
FileNotFoundError: [WinError 3] The system cannot find the path specified: ‘./cogs’

Process finished with exit code 1

This error:

FileNotFoundError: [WinError 3] The system cannot find the path specified: ‘./cogs’

is telling you that python cannot find the folder “./cogs”. Here is the code which is looking for it:

for filenamein os.listdir('./cogs'):

In python, paths are relative to the current working directory. I.e. whatever folder your Bot.main is sitting in, you need to have a “cogs” folder in there.

If you have absolutely no reason to have any cogs for your bot, then comment out the following lines:

for filename in os.listdir('./cogs'):
    if filename.endswith('.py'):
        client.load_extension(f'cogs.{filename[:-3]}')

and the script will stop seeking for a “cogs” folder.

1 Like

I’m having the same issue. Couldn’t figure it out yet. Cogs folder is already inside where the main bot is but when I run the code it’s giving me an error saying " The system cannot find the path specified: ’ ./cogs’

Do you have another way ?

Okay so I was facing the same issue, and it didn’t resolve while the directory name was still cogs. Just rename the directory and open it, should work. Don’t understand the reason properly though!