Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Downloader] [p]findcog doesn't work if cog class is at different level than cog_folder/somefile.py #3177

Closed
jack1142 opened this issue Dec 8, 2019 · 0 comments · Fixed by #3178
Labels
Type: Bug

Comments

@jack1142
Copy link
Member

@jack1142 jack1142 commented Dec 8, 2019

Command bugs

Command name

[p]findcog

What cog is this command from?

Downloader

What were you expecting to happen?

Get cog the command is from

What actually happened?

Got error:

[2019-12-08 23:17:40] [ERROR] red: Exception in command 'findcog'
Traceback (most recent call last):
  File "venv\lib\site-packages\discord\ext\commands\core.py", line 79, in wrapped
    ret = await coro(*args, **kwargs)
  File "venv\lib\site-packages\redbot\cogs\downloader\downloader.py", line 1199, in findcog
    cog_name = self.cog_name_from_instance(cog)
  File "venv\lib\site-packages\redbot\cogs\downloader\downloader.py", line 1182, in cog_name_from_instance
    return splitted[-2]
IndexError: list index out of range

How can we reproduce this issue?

  1. Create a cog with cog class placed in __init__.py
  2. Load the cog.
  3. Use [p]findcog command_from_that_cog
  4. See error

In short, it looks like Downloader.cog_name_from_instance heavily relies on most common file structure in cogs where you have cog class in cog_folder/somefile.py file and it raises if it's in cog_folder/__init__.py and also determines wrong cog name if it's placed in cog_folder/subpackage/somefile.py

@jack1142 jack1142 added the Type: Bug label Dec 8, 2019
@jack1142 jack1142 changed the title [Downloader] `[p]findcog [Downloader] [p]findcog doesn't work if cog class is at different level than cog_folder/somefile.py Dec 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant