phenom4n4n / phen-cogs

My public cogs for Red, Discord bot.
https://phen-cogs.readthedocs.io/en/latest/
MIT License
120 stars 71 forks source link

fixes a bug related to the "st" dev env value #158

Closed japandotorg closed 1 year ago

japandotorg commented 1 year ago
Exception during loading of package:

Traceback (most recent call last):
  File "<root>/MELON/lib/python3.9/site-packages/redbot/core/core_commands.py", line 166, in _load
    await bot.load_extension(spec)
  File "<root>/MELON/lib/python3.9/site-packages/redbot/core/bot.py", line 1736, in load_extension
    await lib.setup(self)
  File "<root>/.local/share/Red-DiscordBot/data/MELON/cogs/CogManager/cogs/slashtags/__init__.py", line 60, in setup
    cog = SlashTags(bot)
  File "<root>/.local/share/Red-DiscordBot/data/MELON/cogs/CogManager/cogs/slashtags/core.py", line 105, in __init__
    bot.add_dev_env_value("st", lambda ctx: self)
  File "<root>/MELON/lib/python3.9/site-packages/redbot/core/bot.py", line 540, in add_dev_env_value
    raise RuntimeError(f"The name {name} is already used.")
RuntimeError: The name st is already used.

this PR fixes this issue.

sravan1946 commented 1 year ago

There is already a remove_dev_env_value being called inside the __unload funtion. just wrap that inside the try except block instead of adding another call to remove_dev_env_value

japandotorg commented 1 year ago

There is already a remove_dev_env_value being called inside the __unload funtion. just wrap that inside the try except block instead of adding another call to remove_dev_env_value

totally missed that, thanks!

phenom4n4n commented 1 year ago

The unload function already is being wrapped in a try except statement and isn’t the reason why the package fails to load. Please remove the changes to the unload function. The try except statement should be around add_dev_env_value on line 105 so that the package can be loaded even if adding the dev value fails.