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

Bridge commands doesn't work with unloading or reloading cogs #1899

Closed
3 tasks done
Soapy7261 opened this issue Jan 31, 2023 · 0 comments · Fixed by #2048
Closed
3 tasks done

Bridge commands doesn't work with unloading or reloading cogs #1899

Soapy7261 opened this issue Jan 31, 2023 · 0 comments · Fixed by #2048
Labels
bug Something isn't working ext.bridge Relating to ext.bridge priority: medium Medium Priority
Milestone

Comments

@Soapy7261
Copy link

Soapy7261 commented Jan 31, 2023

Summary

if you make your bot a bridge bot, and try to unload or reload a cog it'll fail

Reproduction Steps

  1. Make a bridge bot
  2. Make a cog
  3. Unload or reload that (or another) cog
  4. Done

Minimal Reproducible Code

from discord.ext import bridge
bot = bridge.Bot()
bot.load_extension("cog") #Loads all cogs in the cogs folder
bot.run(TOKEN)

Now in a another file called cog.py

from discord.ext import commands, bridge
class Name(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

    @bridge.bridge_command()
    async def ping(self, ctx):
        await ctx.respond ("Pong!")

    @bridge.bridge_command()
    async def action(self, ctx):
        self.bot.unload_extension("cog")
        #self.bot.reload_extension("cog") Same applies
        await ctx.respond ("Observe the error.")

def setup(bot):
    bot.add_cog(Name(bot))

Expected Results

The cog is unloaded or reloaded

Actual Results

The cog is not unloaded or reloaded

Intents

guilds=True, guild_messages=True

System Information

  • Python v3.11.1-final
  • py-cord v2.3.2-final
  • aiohttp v3.7.4.post0
  • system info: Windows 10 10.0.22621 (Not true, im actually running windows 11)

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from display, if visible.

Additional Context

Tracebacl:
Ignoring exception in on_application_command_error
Traceback (most recent call last):
File "C:\Users\MYPCNAME\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\commands\core.py", line 124, in wrapped
ret = await coro(arg)
^^^^^^^^^^^^^^^
File "C:\Users\MYPCNAME\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\commands\core.py", line 976, in _invoke
await self.callback(self.cog, ctx, **kwargs)
File "C:\Users\MYPCNAME\Documents\GitHub\pingernos-py\cogs\cogs.py", line 34, in cogs
raise e
File "C:\Users\MYPCNAME\Documents\GitHub\pingernos-py\cogs\cogs.py", line 29, in cogs
self.bot.unload_extension(f"cogs.{cog}") (Same happens with reload_extension)
File "C:\Users\MYPCNAME\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\cog.py", line 1066, in unload_extension
self._remove_module_references(lib.name)
File "C:\Users\MYPCNAME\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\cog.py", line 722, in _remove_module_references
self.remove_cog(cog_name)
File "C:\Users\MYPCNAME\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\cog.py", line 706, in remove_cog
cog._eject(self)
File "C:\Users\MYPCNAME\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\cog.py", line 592, in _eject
bot.remove_command(command.name)
^^^^^^^^^^^^
AttributeError: 'BridgeCommand' object has no attribute 'name'

Its not the same code as the code i gave, but there's almost no difference and the error will still happen, i also tried it on my other cogs and the same happened.

@Soapy7261 Soapy7261 added the unconfirmed bug A bug report that needs triaging label Jan 31, 2023
@Lulalaby Lulalaby added the priority: medium Medium Priority label Feb 9, 2023
@Lulalaby Lulalaby added this to the v2.5 milestone Feb 10, 2023
@JustaSqu1d JustaSqu1d added bug Something isn't working ext.bridge Relating to ext.bridge and removed unconfirmed bug A bug report that needs triaging labels Mar 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ext.bridge Relating to ext.bridge priority: medium Medium Priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants