Repository: Pycord-Development/pycord

Issue:
[ext.bridge] 'BridgeExtContext' object has no attribute 'delete'
### Summary

Calling `await ctx.delete()` on a message-based bridge command raises an exception.

### Reproduction Steps

• Create a bridge command
• Call `await ctx.reply(...)` followed by `await ctx.delete()`
• Run the command from a message

### Minimal Reproducible Code

```python
import discord
from discord.ext import bridge

intents = discord.Intents.default()
intents.message_content = True

bot = bridge.Bot(command_prefix=".", intents=intents)

@bot.bridge_command()
async def test_delete(ctx: bridge.BridgeContext):
    """Test ctx.delete()"""
    await ctx.reply("Message")
    await ctx.delete()

bot.run(...)
```


### Expected Results

The bot should post a message, which should then be deleted.

### Actual Results

The command works properly when invoked as a slash command; however, when invoked as a **_message command_**, the following exception is raised:

```
Traceback (most recent call last):
  File "/opt/homebrew/lib/python3.10/site-packages/discord/client.py", line 382, in _run_event
    await coro(*args, **kwargs)
  File "main.py", line 70, in on_command_error
    await bridge_error(ctx, error)
  File "main.py", line 89, in bridge_error
    raise error from error
  File "/opt/homebrew/lib/python3.10/site-packages/discord/ext/commands/core.py", line 181, in wrapped
    ret = await coro(*args, **kwargs)
  File "main.py", line 48, in test_delete
    await ctx.delete()
AttributeError: 'BridgeExtContext' object has no attribute 'delete'
```

### Intents

default + message contents

### System Information

- Python v3.10.4-final
- py-cord v2.0.0-beta
    - py-cord pkg_resources: v2.0.0b7
- aiohttp v3.8.1
- system info: Darwin 21.4.0 Darwin Kernel Version 21.4.0: Fri Mar 18 00:47:26 PDT 2022; root:xnu-8020.101.4~15/RELEASE_ARM64_T8101


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

This bug is present both in b7 and in master.


Discussion:
Hm from the looks of the Pycord docs, this should probably be marked as a feature request. `ext.commands.Context` doesn't seem to have a delete function.
@EmreTech It felt like a bug to me, since it works when used as a slash command.
The thing is, it's not available with `BridgeExtContext` because it's not available in `ext.commands.Context`. If it were, then it should work fine.
Agreed, this is more of a feature request. It should also be fairly simple to implement for anyone interested in making a PR.
If it's a feature request, then it's a feature request. It felt like a bug to me, as a user, because it worked in one context and not the other 🤷‍♂️

Resolving patch:
diff --git a/discord/commands/context.py b/discord/commands/context.py
--- a/discord/commands/context.py
+++ b/discord/commands/context.py
@@ -256,13 +256,29 @@ def defer(self) -> Callable[..., Awaitable[None]]:
     def followup(self) -> Webhook:
         return self.interaction.followup
 
-    async def delete(self):
-        """Calls :attr:`~discord.commands.ApplicationContext.respond`.
-        If the response is done, then calls :attr:`~discord.commands.ApplicationContext.respond` first."""
+    async def delete(self, *, delay: Optional[float] = None) -> None:
+        """|coro|
+
+        Deletes the original interaction response message.
+
+        This is a higher level interface to :meth:`Interaction.delete_original_message`.
+
+        Parameters
+        -----------
+        delay: Optional[:class:`float`]
+            If provided, the number of seconds to wait before deleting the message.
+
+        Raises
+        -------
+        HTTPException
+            Deleting the message failed.
+        Forbidden
+            You do not have proper permissions to delete the message.
+        """
         if not self.interaction.response.is_done():
             await self.defer()
 
-        return await self.interaction.delete_original_message()
+        return await self.interaction.delete_original_message(delay=delay)
 
     @property
     def edit(self) -> Callable[..., Awaitable[InteractionMessage]]:
diff --git a/discord/ext/bridge/context.py b/discord/ext/bridge/context.py
--- a/discord/ext/bridge/context.py
+++ b/discord/ext/bridge/context.py
@@ -145,7 +145,7 @@ def __init__(self, *args, **kwargs):
 
     async def _respond(self, *args, **kwargs) -> Message:
         message = await self._get_super("reply")(*args, **kwargs)
-        if self._original_response_message == None:
+        if self._original_response_message is None:
             self._original_response_message = message
         return message
 
@@ -155,6 +155,21 @@ async def _defer(self, *args, **kwargs) -> None:
     async def _edit(self, *args, **kwargs) -> Message:
         return await self._original_response_message.edit(*args, **kwargs)
 
+    async def delete(self, *, delay: Optional[float] = None, reason: Optional[str] = None) -> None:
+        """|coro|
+
+        Deletes the original response message, if it exists.
+
+        Parameters
+        -----------
+        delay: Optional[:class:`float`]
+            If provided, the number of seconds to wait before deleting the message.
+        reason: Optional[:class:`str`]
+            The reason for deleting the message. Shows up on the audit log.
+        """
+        if self._original_response_message:
+            await self._original_response_message.delete(delay=delay, reason=reason)
+
 
 if TYPE_CHECKING:
     # This is a workaround for mypy not being able to resolve the type of BridgeCommand.


Test patch: