Repository: Pycord-Development/pycord

Issue:
Strange behaviour when using commands in group
### Summary

The bot thinks "self" is "ctx"

### Reproduction Steps

Have commands inside a cog class

### Minimal Reproducible Code

_No response_

### Expected Results

Seperation between ctx and self

### Actual Results

When attempting to call local functions inside the class, it does "ctx" instead.

`AttributeError: 'CustomContext' object has no attribute 'get_ticket_info'`
![](https://i.alexflipnote.dev/3TouUDc.png)

![](https://i.alexflipnote.dev/5iDdEva.png)

## Traceback
```py
  File "/home/alexflipnote/.pyenv/versions/3.10.0/lib/python3.10/site-packages/discord/ext/commands/core.py", line 173, in wrapped
    ret = await coro(*args, **kwargs)
  File "/home/alexflipnote/xelA/cogs/tickets.py", line 903, in tickets_close
    fetch_guild = await self.get_ticket_info(ctx.guild.id)
AttributeError: 'CustomContext' object has no attribute 'get_ticket_info'
```

### Intents

guilds, members, messages, bans, emojis, voice_states, reactions

### System Information

```
alexflipnote@xelaservur:~/xelA$ python -m discord -v
- Python v3.10.0-final
- py-cord v2.0.0-alpha
    - py-cord pkg_resources: v2.0.0a4514+g125db3ab
- aiohttp v3.8.1
- system info: Linux 4.19.0-14-amd64 #1 SMP Debian 4.19.171-2 (2021-01-30)
```

### Checklist

- [X] I have searched the open issues for duplicates.
- [X] I have shown the entire traceback, if possible.
- [X] I have removed my token from display, if visible.

### Additional Context

It works fine on any versions up to git version **125db3a**, however after updating to the latest **faeaa15** that fixes memory leak, it went upsidedown for me.



## UPDATE
Thought it was custom context that made it break, it's the group (subcommand) function to commands that did instead.


Discussion:
This is the "CustomContext"
![image](https://user-images.githubusercontent.com/19587382/146242698-ffb8ca9d-8ef9-4f24-ae64-77ba1624b8b2.png)

It broke at 6646129, doing the command makes it show a random \<ctx\>
![image](https://user-images.githubusercontent.com/19587382/146244005-eb71808e-07b2-45ea-b6bb-7730dc8b1fae.png)

But there are no different arguments to the command at all 
![image](https://user-images.githubusercontent.com/19587382/146244098-3ac4df3d-fa07-4c66-8c1c-f8b172f7da44.png)


meh
It appears `self` is being ignored.
It only happens when you attempt to do commands in group (sub-command)
![image](https://user-images.githubusercontent.com/19587382/146246388-6d95f62c-a649-4969-a76c-1f971fc1e1ee.png)
![image](https://user-images.githubusercontent.com/19587382/146246497-a3ede6ba-83ea-4f9f-bf9b-e000f28e1bf7.png)

This was tested by simply addingt those three functions above, inside the Admin class
https://github.com/AlexFlipnote/discord_bot.py/blob/master/cogs/admin.py
I believe these are the specific lines causing the behavior:

https://github.com/Pycord-Development/pycord/blob/faeaa159d43cfec8ef4f21fd85183df820a9b42e/discord/cog.py#L148-L153
I have a fix, working on validating and will open a PR.

Resolving patch:
diff --git a/discord/cog.py b/discord/cog.py
--- a/discord/cog.py
+++ b/discord/cog.py
@@ -146,7 +146,7 @@ def __new__(cls: Type[CogMeta], *args: Any, **kwargs: Any) -> CogMeta:
                     del listeners[elem]
 
                 try:
-                    if getattr(value, "parent") is not None:
+                    if getattr(value, "parent") is not None and isinstance(value, ApplicationCommand):
                         # Skip commands if they are a part of a group
                         continue
                 except AttributeError:


Test patch: