Repository: Pycord-Development/pycord

Issue:
'Bot' object has no attribute '_bridge_commands'
### Summary

@bot.bridge_command() inside of a cog causes a crash.

### Reproduction Steps

1. Make a bridge command inside of a cog
2. Enter bot token
3. Attempt to start bot
4. Bot fails to start

### Minimal Reproducible Code

```python
# main.py
import discord
from discord.ext import bridge, commands

from cogfile import SampleCog

intents = discord.Intents.all()
bridge_bot = bridge.Bot(command_prefix=commands.when_mentioned_or("!"), intents=intents)

bridge_bot.add_cog(SampleCog())
bridge_bot.run("token")

# cogfile.py

from discord.ext import commands
from discord.ext.bridge import bot


class SampleCog(commands.Cog):

	@bot.bridge_command()
	async def test(self, ctx):
		await ctx.respond("test")
```


### Expected Results

The cog will be added, and the bot will start as in 2.3.0.

### Actual Results

The bot crashes with an error and will not start.

```python
Traceback (most recent call last):
  File "C:\Users\Nicholas\Documents\GitHub\TitanBot\test.py", line 9, in <module>
    bridge_bot.add_cog(SampleCog())
  File "C:\Users\Nicholas\Documents\GitHub\TitanBot\venv-3.10\lib\site-packages\discord\cog.py", line 656, in add_cog
    cog = cog._inject(self)
  File "C:\Users\Nicholas\Documents\GitHub\TitanBot\venv-3.10\lib\site-packages\discord\cog.py", line 545, in _inject
    bot._bridge_commands.append(command)
AttributeError: 'Bot' object has no attribute '_bridge_commands'. Did you mean: 'bridge_commands'?
```

### Intents

All

### System Information

- Python v3.10.7-final
- py-cord v2.3.1-final
- aiohttp v3.8.3
- system info: Windows 10 10.0.22621

### 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

Works fine in 2.3.0. Tested on both Python 3.10 and 3.11, same results.

May be related to #1800.


Discussion:
i can confirm that this is an actual bug

when removeing the _ in discord/cog.py the error gos away 

CUbot is a subclass of commands

`Traceback (most recent call last):
  File "/home/pooh/.local/share/virtualenvs/refractor-9meiG1iJ/lib/python3.10/site-packages/discord/cog.py", line 786, in _load_from_module_spec
    setup(self)
  File "/mnt/sharessd/code/python/utachi/refractor/bot/extendtions/music/__main__.py", line 536, in setup
    client.add_cog(Music(client))
  File "/home/pooh/.local/share/virtualenvs/refractor-9meiG1iJ/lib/python3.10/site-packages/discord/cog.py", line 656, in add_cog
    cog = cog._inject(self)
  File "/home/pooh/.local/share/virtualenvs/refractor-9meiG1iJ/lib/python3.10/site-packages/discord/cog.py", line 545, in _inject
    bot._bridge_commands.append(command)
AttributeError: 'CUbot' object has no attribute '_bridge_commands'. Did you mean: 'bridge_commands'?

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/lib64/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib64/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/mnt/sharessd/code/python/utachi/refractor/bot/__main__.py", line 115, in <module>
    run()
  File "/mnt/sharessd/code/python/utachi/refractor/bot/__main__.py", line 101, in run
    client.load_extension(name='bot.extendtions.music.__main__')
  File "/home/pooh/.local/share/virtualenvs/refractor-9meiG1iJ/lib/python3.10/site-packages/discord/cog.py", line 910, in load_extension
    self._load_from_module_spec(spec, name)
  File "/home/pooh/.local/share/virtualenvs/refractor-9meiG1iJ/lib/python3.10/site-packages/discord/cog.py", line 791, in _load_from_module_spec
    raise errors.ExtensionFailed(key, e) from e
discord.errors.ExtensionFailed: Extension 'bot.extendtions.music.__main__' raised an error: AttributeError: 'CUbot' object has no attribute '_bridge_commands'`

Resolving patch:
diff --git a/discord/cog.py b/discord/cog.py
--- a/discord/cog.py
+++ b/discord/cog.py
@@ -542,7 +542,7 @@ def _inject(self: CogT, bot) -> CogT:
 
         for index, command in enumerate(self.__cog_commands__):
             if hasattr(command, "add_to"):
-                bot._bridge_commands.append(command)
+                bot.bridge_commands.append(command)
                 continue
 
             command._set_cog(self)
diff --git a/discord/ext/bridge/bot.py b/discord/ext/bridge/bot.py
--- a/discord/ext/bridge/bot.py
+++ b/discord/ext/bridge/bot.py
@@ -49,10 +49,6 @@ def bridge_commands(self) -> list[BridgeCommand | BridgeCommandGroup]:
 
         return cmds
 
-    @bridge_commands.setter
-    def bridge_commands(self, cmds):
-        self._bridge_commands = cmds
-
     async def get_application_context(
         self, interaction: Interaction, cls=None
     ) -> BridgeApplicationContext:
@@ -74,10 +70,7 @@ def add_bridge_command(self, command: BridgeCommand):
         # Ignore the type hinting error here. All subclasses of BotBase pass the type checks.
         command.add_to(self)  # type: ignore
 
-        if getattr(self, "_bridge_commands", None) is None:
-            self._bridge_commands = []
-
-        self._bridge_commands.append(command)
+        self.bridge_commands.append(command)
 
     def bridge_command(self, **kwargs):
         """A shortcut decorator that invokes :func:`bridge_command` and adds it to


Test patch: