Cog-Creators / Red-DiscordBot

A multi-function Discord bot
https://docs.discord.red
GNU General Public License v3.0
4.81k stars 2.31k forks source link

Creating a group of hybrid commands without app_command in a cog causes an error. #5980

Closed AAA3A-AAA3A closed 1 year ago

AAA3A-AAA3A commented 1 year ago

What Red version are you using?

3.5.0.dev310+g5e446ad1 (dpy 2.2.0a)

What were you trying to do?

Hello,

I noticed that there was an error when adding a cog with a hybrid command group if there is no app_command, on the latest version of dpy2. As a result, some of my cogs are no longer working. Recently, some of dpy's private methods have been removed and Red seems to be using them here. Flame tested the same eval as me in #testing the main server on a non-Red dpy bot and there is no error, so this is in Red.

Thanks in advance, AAA3A

What did you expect to happen?

The cog should have been added correctly.

What actually happened?

Traceback (most recent call last):
  File "{USERPROFILE}\Documents\GitHub\Red-DiscordBot\redbot\core\dev_commands.py", line 216, in _eval
    result = await func()
  File "<string>", line 8, in func
  File "{USERPROFILE}\redenv\lib\site-packages\discord\ext\commands\cog.py", line 343, in __new__
    app_command = app_command._copy_with(parent=group_parent, binding=self)
AttributeError: '_MissingSentinel' object has no attribute '_copy_with'

How can we reproduce this error?

Run this eval or load a cog with this code:

class Cog(commands.Cog):
    @commands.hybrid_group(with_app_command=False)
    async def test(self, ctx: commands.Context):
        pass
await ctx.bot.remove_cog("Cog")
await ctx.bot.add_cog(Cog())

Anything else?

No response

AAA3A-AAA3A commented 1 year ago

Actually it was an error in dpy2.2.0a. My PR was merged this morning on the dpy repo to fix this error.