#command file load error for bot

26 messages · Page 1 of 1 (latest)

azure pilot
#

This is the error I am getting

#

2023-09-07 13:17:01 ERROR discord.client Ignoring exception in on_ready
Traceback (most recent call last):
File "D:\PYTHON\Python Interface\lib\site-packages\discord\client.py", line 441, in _run_event
await coro(*args, **kwargs)
File "d:\Projects\Discord BOT (PYTHON)\main.py", line 29, in on_ready
await bot.load_extension(f"{cmd_file.name[:-3]}")
File "D:\PYTHON\Python Interface\lib\site-packages\discord\ext\commands\bot.py", line 1011, in load_extension
raise errors.ExtensionNotFound(name)
discord.ext.commands.errors.ExtensionNotFound: Extension 'math_cmd' could not be loaded.

This is the error messgae

#

This is the setup function in math_cmd

maiden inlet
#

I'm pretty sure you need to load com.{cmd_file.stem}

(cmd_file.stem is the file's name without the file extension)

azure pilot
#

@maiden inlet It's not working

maiden inlet
#

It is working. You just have a bug in your extension file. You can't import commands from discord

azure pilot
#

oh

maiden inlet
#

You should read the error messages

azure pilot
#

i read it and it said the error was in com.math_cmd, so i thought there was another error in the code

maiden inlet
#

It is... but it has to do with the code in your math_cmd extension

#

One of your imports in that file doesn't work

azure pilot
#

These are the only imports in it

maiden inlet
#

You can't import commands from discord

#

Commands is a module and it's not included in the discord module, so you have to import discord.commands directly

azure pilot
#

oh

azure pilot
#

@maiden inletIt worked, thx for the help..

hey can you please explain why I had to use com. (folder name) with the file name?

maiden inlet
#

So it knows what package to import the module from.

azure pilot
#

yeah but I have already done that in settings.py in cmds variable

maiden inlet
#

You could have 5 packages/folders with the same files in them, it needs to know which one to use

#

The code doesn't know that though

#

You know what's in settings

#

The code doesn't magically load values from settings