We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[ext.bridge] Ephemeral kwarg causing errors in defer() and respond()
### Summary

Using the ephemeral= keyword argument causes errors when it is passed into the prefix-command version of the bridge command.

### Reproduction Steps

Using any `ephemeral` keyword arguments

### Minimal Reproducible Code

```python
    @bridge_command(name="commands", description="This page lists all commands")
    async def _commands(self, context: ApplicationContext) -> None:
        await context.defer(ephemeral=True)
        await context.respond("Commands List", ephemeral=True)
```


### Expected Results

The ephemeral keyword argument should instead be ignored. This could be as simple as a:
```py
if kwargs.get("ephemeral") is not None:
    del kwargs["ephemeral"]
```
This is in fact exactly what I added in both `discord/message.py` line 1625 and `discord/ext/bridge/context.py` line 153 to get it to work temporarily.

### Actual Results

```py
Ignoring exception in command commands:
Traceback (most recent call last):
  File "/home/krishnan/Coding/Hobby/ChessCord/ChessCordv2.0/venv/lib/python3.10/site-packages/discord/ext/commands/core.py", line 181, in wrapped
    ret = await coro(*args, **kwargs)
  File "/home/krishnan/Coding/Hobby/ChessCord/ChessCordv2.0/slash/help.py", line 38, in _commands
    await context.defer(ephemeral=True)
  File "/home/krishnan/Coding/Hobby/ChessCord/ChessCordv2.0/venv/lib/python3.10/site-packages/discord/ext/bridge/context.py", line 101, in defer
    return await self._defer(*args, **kwargs)
  File "/home/krishnan/Coding/Hobby/ChessCord/ChessCordv2.0/venv/lib/python3.10/site-packages/discord/ext/bridge/context.py", line 153, in _defer
    return await self._get_super("trigger_typing")(*args, **kwargs)
TypeError: Messageable.trigger_typing() got an unexpected keyword argument 'ephemeral'
```
and
```py
Ignoring exception in command commands:
Traceback (most recent call last):
  File "/home/krishnan/Coding/Hobby/ChessCord/ChessCordv2.0/venv/lib/python3.10/site-packages/discord/ext/commands/core.py", line 181, in wrapped
    ret = await coro(*args, **kwargs)
  File "/home/krishnan/Coding/Hobby/ChessCord/ChessCordv2.0/slash/help.py", line 40, in _commands
    await context.respond(
  File "/home/krishnan/Coding/Hobby/ChessCord/ChessCordv2.0/venv/lib/python3.10/site-packages/discord/ext/bridge/context.py", line 81, in respond
    return await self._respond(*args, **kwargs)
  File "/home/krishnan/Coding/Hobby/ChessCord/ChessCordv2.0/venv/lib/python3.10/site-packages/discord/ext/bridge/context.py", line 147, in _respond
    message = await self._get_super("reply")(*args, **kwargs)
  File "/home/krishnan/Coding/Hobby/ChessCord/ChessCordv2.0/venv/lib/python3.10/site-packages/discord/ext/commands/context.py", line 399, in reply
    return await self.message.reply(content, **kwargs)
  File "/home/krishnan/Coding/Hobby/ChessCord/ChessCordv2.0/venv/lib/python3.10/site-packages/discord/message.py", line 1625, in reply
    return await self.channel.send(content, reference=self, **kwargs)
TypeError: Messageable.send() got an unexpected keyword argument 'ephemeral'
```

### Intents

discord.Intents.all

### System Information

- Python v3.10.5-final
- py-cord v2.0.0-candidate
    - py-cord pkg_resources: v2.0.0rc1
- aiohttp v3.8.1
- system info: Linux 5.15.48-1-MANJARO #1 SMP PREEMPT Thu Jun 16 12:33:56 UTC 2022

### 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 can also apply to other slash-command-specific kwargs, which I can't specifically think of off the top of my head.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `discord/ext/bridge/context.py`
Content:
```
1 """
2 The MIT License (MIT)
3 
4 Copyright (c) 2015-2021 Rapptz
5 Copyright (c) 2021-present Pycord Development
6 
7 Permission is hereby granted, free of charge, to any person obtaining a
8 copy of this software and associated documentation files (the "Software"),
9 to deal in the Software without restriction, including without limitation
10 the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 and/or sell copies of the Software, and to permit persons to whom the
12 Software is furnished to do so, subject to the following conditions:
13 
14 The above copyright notice and this permission notice shall be included in
15 all copies or substantial portions of the Software.
16 
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 DEALINGS IN THE SOFTWARE.
24 """
25 from abc import ABC, abstractmethod
26 from typing import TYPE_CHECKING, Any, Optional, Union
27 
28 from discord.commands import ApplicationContext
29 from discord.interactions import Interaction, InteractionMessage
30 from discord.message import Message
31 from discord.webhook import WebhookMessage
32 
33 from ..commands import Context
34 
35 __all__ = ("BridgeContext", "BridgeExtContext", "BridgeApplicationContext")
36 
37 
38 class BridgeContext(ABC):
39     """
40     The base context class for compatibility commands. This class is an :class:`ABC` (abstract base class), which is
41     subclassed by :class:`BridgeExtContext` and :class:`BridgeApplicationContext`. The methods in this class are meant
42     to give parity between the two contexts, while still allowing for all of their functionality.
43 
44     When this is passed to a command, it will either be passed as :class:`BridgeExtContext`, or
45     :class:`BridgeApplicationContext`. Since they are two separate classes, it is quite simple to use :meth:`isinstance`
46     to make different functionality for each context. For example, if you want to respond to a command with the command
47     type that it was invoked with, you can do the following:
48 
49     .. code-block:: python3
50 
51         @bot.bridge_command()
52         async def example(ctx: BridgeContext):
53             if isinstance(ctx, BridgeExtContext):
54                 command_type = "Traditional (prefix-based) command"
55             elif isinstance(ctx, BridgeApplicationContext):
56                 command_type = "Application command"
57             await ctx.send(f"This command was invoked with a(n) {command_type}.")
58 
59     .. versionadded:: 2.0
60     """
61 
62     @abstractmethod
63     async def _respond(self, *args, **kwargs) -> Union[Union[Interaction, WebhookMessage], Message]:
64         ...
65 
66     @abstractmethod
67     async def _defer(self, *args, **kwargs) -> None:
68         ...
69 
70     @abstractmethod
71     async def _edit(self, *args, **kwargs) -> Union[InteractionMessage, Message]:
72         ...
73 
74     async def respond(self, *args, **kwargs) -> Union[Union[Interaction, WebhookMessage], Message]:
75         """|coro|
76 
77         Responds to the command with the respective response type to the current context. In :class:`BridgeExtContext`,
78         this will be :meth:`~.ExtContext.reply` while in :class:`BridgeApplicationContext`, this will be
79         :meth:`~.ApplicationContext.respond`.
80         """
81         return await self._respond(*args, **kwargs)
82 
83     async def reply(self, *args, **kwargs) -> Union[Union[Interaction, WebhookMessage], Message]:
84         """|coro|
85 
86         Alias for :meth:`~.BridgeContext.respond`.
87         """
88         return await self.respond(*args, **kwargs)
89 
90     async def defer(self, *args, **kwargs) -> None:
91         """|coro|
92 
93         Defers the command with the respective approach to the current context. In :class:`BridgeExtContext`, this will
94         be :meth:`~.ExtContext.trigger_typing` while in :class:`BridgeApplicationContext`, this will be
95         :meth:`~.ApplicationContext.defer`.
96 
97         .. note::
98             There is no ``trigger_typing`` alias for this method. ``trigger_typing`` will always provide the same
99             functionality across contexts.
100         """
101         return await self._defer(*args, **kwargs)
102 
103     async def edit(self, *args, **kwargs) -> Union[InteractionMessage, Message]:
104         """|coro|
105 
106         Edits the original response message with the respective approach to the current context. In
107         :class:`BridgeExtContext`, this will have a custom approach where :meth:`.respond` caches the message to be
108         edited here. In :class:`BridgeApplicationContext`, this will be :meth:`~.ApplicationContext.edit`.
109         """
110         return await self._edit(*args, **kwargs)
111 
112     def _get_super(self, attr: str) -> Optional[Any]:
113         return getattr(super(), attr)
114 
115 
116 class BridgeApplicationContext(BridgeContext, ApplicationContext):
117     """
118     The application context class for compatibility commands. This class is a subclass of :class:`BridgeContext` and
119     :class:`ApplicationContext`. This class is meant to be used with :class:`BridgeCommand`.
120 
121     .. versionadded:: 2.0
122     """
123 
124     async def _respond(self, *args, **kwargs) -> Union[Interaction, WebhookMessage]:
125         return await self._get_super("respond")(*args, **kwargs)
126 
127     async def _defer(self, *args, **kwargs) -> None:
128         return await self._get_super("defer")(*args, **kwargs)
129 
130     async def _edit(self, *args, **kwargs) -> InteractionMessage:
131         return await self._get_super("edit")(*args, **kwargs)
132 
133 
134 class BridgeExtContext(BridgeContext, Context):
135     """
136     The ext.commands context class for compatibility commands. This class is a subclass of :class:`BridgeContext` and
137     :class:`Context`. This class is meant to be used with :class:`BridgeCommand`.
138 
139     .. versionadded:: 2.0
140     """
141 
142     def __init__(self, *args, **kwargs):
143         super().__init__(*args, **kwargs)
144         self._original_response_message: Optional[Message] = None
145 
146     async def _respond(self, *args, **kwargs) -> Message:
147         message = await self._get_super("reply")(*args, **kwargs)
148         if self._original_response_message is None:
149             self._original_response_message = message
150         return message
151 
152     async def _defer(self, *args, **kwargs) -> None:
153         return await self._get_super("trigger_typing")(*args, **kwargs)
154 
155     async def _edit(self, *args, **kwargs) -> Message:
156         return await self._original_response_message.edit(*args, **kwargs)
157 
158     async def delete(self, *, delay: Optional[float] = None, reason: Optional[str] = None) -> None:
159         """|coro|
160 
161         Deletes the original response message, if it exists.
162 
163         Parameters
164         -----------
165         delay: Optional[:class:`float`]
166             If provided, the number of seconds to wait before deleting the message.
167         reason: Optional[:class:`str`]
168             The reason for deleting the message. Shows up on the audit log.
169         """
170         if self._original_response_message:
171             await self._original_response_message.delete(delay=delay, reason=reason)
172 
173 
174 if TYPE_CHECKING:
175     # This is a workaround for mypy not being able to resolve the type of BridgeCommand.
176     class BridgeContext(ApplicationContext, Context):
177         ...
178
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

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
@@ -144,12 +144,14 @@
         self._original_response_message: Optional[Message] = None
 
     async def _respond(self, *args, **kwargs) -> Message:
+        kwargs.pop("ephemeral", None)
         message = await self._get_super("reply")(*args, **kwargs)
         if self._original_response_message is None:
             self._original_response_message = message
         return message
 
     async def _defer(self, *args, **kwargs) -> None:
+        kwargs.pop("ephemeral", None)
         return await self._get_super("trigger_typing")(*args, **kwargs)
 
     async def _edit(self, *args, **kwargs) -> Message:

{"golden_diff": "diff --git a/discord/ext/bridge/context.py b/discord/ext/bridge/context.py\n--- a/discord/ext/bridge/context.py\n+++ b/discord/ext/bridge/context.py\n@@ -144,12 +144,14 @@\n         self._original_response_message: Optional[Message] = None\n \n     async def _respond(self, *args, **kwargs) -> Message:\n+        kwargs.pop(\"ephemeral\", None)\n         message = await self._get_super(\"reply\")(*args, **kwargs)\n         if self._original_response_message is None:\n             self._original_response_message = message\n         return message\n \n     async def _defer(self, *args, **kwargs) -> None:\n+        kwargs.pop(\"ephemeral\", None)\n         return await self._get_super(\"trigger_typing\")(*args, **kwargs)\n \n     async def _edit(self, *args, **kwargs) -> Message:\n", "issue": "[ext.bridge] Ephemeral kwarg causing errors in defer() and respond()\n### Summary\r\n\r\nUsing the ephemeral= keyword argument causes errors when it is passed into the prefix-command version of the bridge command.\r\n\r\n### Reproduction Steps\r\n\r\nUsing any `ephemeral` keyword arguments\r\n\r\n### Minimal Reproducible Code\r\n\r\n```python\r\n    @bridge_command(name=\"commands\", description=\"This page lists all commands\")\r\n    async def _commands(self, context: ApplicationContext) -> None:\r\n        await context.defer(ephemeral=True)\r\n        await context.respond(\"Commands List\", ephemeral=True)\r\n```\r\n\r\n\r\n### Expected Results\r\n\r\nThe ephemeral keyword argument should instead be ignored. This could be as simple as a:\r\n```py\r\nif kwargs.get(\"ephemeral\") is not None:\r\n    del kwargs[\"ephemeral\"]\r\n```\r\nThis is in fact exactly what I added in both `discord/message.py` line 1625 and `discord/ext/bridge/context.py` line 153 to get it to work temporarily.\r\n\r\n### Actual Results\r\n\r\n```py\r\nIgnoring exception in command commands:\r\nTraceback (most recent call last):\r\n  File \"/home/krishnan/Coding/Hobby/ChessCord/ChessCordv2.0/venv/lib/python3.10/site-packages/discord/ext/commands/core.py\", line 181, in wrapped\r\n    ret = await coro(*args, **kwargs)\r\n  File \"/home/krishnan/Coding/Hobby/ChessCord/ChessCordv2.0/slash/help.py\", line 38, in _commands\r\n    await context.defer(ephemeral=True)\r\n  File \"/home/krishnan/Coding/Hobby/ChessCord/ChessCordv2.0/venv/lib/python3.10/site-packages/discord/ext/bridge/context.py\", line 101, in defer\r\n    return await self._defer(*args, **kwargs)\r\n  File \"/home/krishnan/Coding/Hobby/ChessCord/ChessCordv2.0/venv/lib/python3.10/site-packages/discord/ext/bridge/context.py\", line 153, in _defer\r\n    return await self._get_super(\"trigger_typing\")(*args, **kwargs)\r\nTypeError: Messageable.trigger_typing() got an unexpected keyword argument 'ephemeral'\r\n```\r\nand\r\n```py\r\nIgnoring exception in command commands:\r\nTraceback (most recent call last):\r\n  File \"/home/krishnan/Coding/Hobby/ChessCord/ChessCordv2.0/venv/lib/python3.10/site-packages/discord/ext/commands/core.py\", line 181, in wrapped\r\n    ret = await coro(*args, **kwargs)\r\n  File \"/home/krishnan/Coding/Hobby/ChessCord/ChessCordv2.0/slash/help.py\", line 40, in _commands\r\n    await context.respond(\r\n  File \"/home/krishnan/Coding/Hobby/ChessCord/ChessCordv2.0/venv/lib/python3.10/site-packages/discord/ext/bridge/context.py\", line 81, in respond\r\n    return await self._respond(*args, **kwargs)\r\n  File \"/home/krishnan/Coding/Hobby/ChessCord/ChessCordv2.0/venv/lib/python3.10/site-packages/discord/ext/bridge/context.py\", line 147, in _respond\r\n    message = await self._get_super(\"reply\")(*args, **kwargs)\r\n  File \"/home/krishnan/Coding/Hobby/ChessCord/ChessCordv2.0/venv/lib/python3.10/site-packages/discord/ext/commands/context.py\", line 399, in reply\r\n    return await self.message.reply(content, **kwargs)\r\n  File \"/home/krishnan/Coding/Hobby/ChessCord/ChessCordv2.0/venv/lib/python3.10/site-packages/discord/message.py\", line 1625, in reply\r\n    return await self.channel.send(content, reference=self, **kwargs)\r\nTypeError: Messageable.send() got an unexpected keyword argument 'ephemeral'\r\n```\r\n\r\n### Intents\r\n\r\ndiscord.Intents.all\r\n\r\n### System Information\r\n\r\n- Python v3.10.5-final\r\n- py-cord v2.0.0-candidate\r\n    - py-cord pkg_resources: v2.0.0rc1\r\n- aiohttp v3.8.1\r\n- system info: Linux 5.15.48-1-MANJARO #1 SMP PREEMPT Thu Jun 16 12:33:56 UTC 2022\r\n\r\n### Checklist\r\n\r\n- [X] I have searched the open issues for duplicates.\r\n- [X] I have shown the entire traceback, if possible.\r\n- [X] I have removed my token from display, if visible.\r\n\r\n### Additional Context\r\n\r\nThis can also apply to other slash-command-specific kwargs, which I can't specifically think of off the top of my head.\n", "before_files": [{"content": "\"\"\"\nThe MIT License (MIT)\n\nCopyright (c) 2015-2021 Rapptz\nCopyright (c) 2021-present Pycord Development\n\nPermission is hereby granted, free of charge, to any person obtaining a\ncopy of this software and associated documentation files (the \"Software\"),\nto deal in the Software without restriction, including without limitation\nthe rights to use, copy, modify, merge, publish, distribute, sublicense,\nand/or sell copies of the Software, and to permit persons to whom the\nSoftware is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\nOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\nFROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\nDEALINGS IN THE SOFTWARE.\n\"\"\"\nfrom abc import ABC, abstractmethod\nfrom typing import TYPE_CHECKING, Any, Optional, Union\n\nfrom discord.commands import ApplicationContext\nfrom discord.interactions import Interaction, InteractionMessage\nfrom discord.message import Message\nfrom discord.webhook import WebhookMessage\n\nfrom ..commands import Context\n\n__all__ = (\"BridgeContext\", \"BridgeExtContext\", \"BridgeApplicationContext\")\n\n\nclass BridgeContext(ABC):\n    \"\"\"\n    The base context class for compatibility commands. This class is an :class:`ABC` (abstract base class), which is\n    subclassed by :class:`BridgeExtContext` and :class:`BridgeApplicationContext`. The methods in this class are meant\n    to give parity between the two contexts, while still allowing for all of their functionality.\n\n    When this is passed to a command, it will either be passed as :class:`BridgeExtContext`, or\n    :class:`BridgeApplicationContext`. Since they are two separate classes, it is quite simple to use :meth:`isinstance`\n    to make different functionality for each context. For example, if you want to respond to a command with the command\n    type that it was invoked with, you can do the following:\n\n    .. code-block:: python3\n\n        @bot.bridge_command()\n        async def example(ctx: BridgeContext):\n            if isinstance(ctx, BridgeExtContext):\n                command_type = \"Traditional (prefix-based) command\"\n            elif isinstance(ctx, BridgeApplicationContext):\n                command_type = \"Application command\"\n            await ctx.send(f\"This command was invoked with a(n) {command_type}.\")\n\n    .. versionadded:: 2.0\n    \"\"\"\n\n    @abstractmethod\n    async def _respond(self, *args, **kwargs) -> Union[Union[Interaction, WebhookMessage], Message]:\n        ...\n\n    @abstractmethod\n    async def _defer(self, *args, **kwargs) -> None:\n        ...\n\n    @abstractmethod\n    async def _edit(self, *args, **kwargs) -> Union[InteractionMessage, Message]:\n        ...\n\n    async def respond(self, *args, **kwargs) -> Union[Union[Interaction, WebhookMessage], Message]:\n        \"\"\"|coro|\n\n        Responds to the command with the respective response type to the current context. In :class:`BridgeExtContext`,\n        this will be :meth:`~.ExtContext.reply` while in :class:`BridgeApplicationContext`, this will be\n        :meth:`~.ApplicationContext.respond`.\n        \"\"\"\n        return await self._respond(*args, **kwargs)\n\n    async def reply(self, *args, **kwargs) -> Union[Union[Interaction, WebhookMessage], Message]:\n        \"\"\"|coro|\n\n        Alias for :meth:`~.BridgeContext.respond`.\n        \"\"\"\n        return await self.respond(*args, **kwargs)\n\n    async def defer(self, *args, **kwargs) -> None:\n        \"\"\"|coro|\n\n        Defers the command with the respective approach to the current context. In :class:`BridgeExtContext`, this will\n        be :meth:`~.ExtContext.trigger_typing` while in :class:`BridgeApplicationContext`, this will be\n        :meth:`~.ApplicationContext.defer`.\n\n        .. note::\n            There is no ``trigger_typing`` alias for this method. ``trigger_typing`` will always provide the same\n            functionality across contexts.\n        \"\"\"\n        return await self._defer(*args, **kwargs)\n\n    async def edit(self, *args, **kwargs) -> Union[InteractionMessage, Message]:\n        \"\"\"|coro|\n\n        Edits the original response message with the respective approach to the current context. In\n        :class:`BridgeExtContext`, this will have a custom approach where :meth:`.respond` caches the message to be\n        edited here. In :class:`BridgeApplicationContext`, this will be :meth:`~.ApplicationContext.edit`.\n        \"\"\"\n        return await self._edit(*args, **kwargs)\n\n    def _get_super(self, attr: str) -> Optional[Any]:\n        return getattr(super(), attr)\n\n\nclass BridgeApplicationContext(BridgeContext, ApplicationContext):\n    \"\"\"\n    The application context class for compatibility commands. This class is a subclass of :class:`BridgeContext` and\n    :class:`ApplicationContext`. This class is meant to be used with :class:`BridgeCommand`.\n\n    .. versionadded:: 2.0\n    \"\"\"\n\n    async def _respond(self, *args, **kwargs) -> Union[Interaction, WebhookMessage]:\n        return await self._get_super(\"respond\")(*args, **kwargs)\n\n    async def _defer(self, *args, **kwargs) -> None:\n        return await self._get_super(\"defer\")(*args, **kwargs)\n\n    async def _edit(self, *args, **kwargs) -> InteractionMessage:\n        return await self._get_super(\"edit\")(*args, **kwargs)\n\n\nclass BridgeExtContext(BridgeContext, Context):\n    \"\"\"\n    The ext.commands context class for compatibility commands. This class is a subclass of :class:`BridgeContext` and\n    :class:`Context`. This class is meant to be used with :class:`BridgeCommand`.\n\n    .. versionadded:: 2.0\n    \"\"\"\n\n    def __init__(self, *args, **kwargs):\n        super().__init__(*args, **kwargs)\n        self._original_response_message: Optional[Message] = None\n\n    async def _respond(self, *args, **kwargs) -> Message:\n        message = await self._get_super(\"reply\")(*args, **kwargs)\n        if self._original_response_message is None:\n            self._original_response_message = message\n        return message\n\n    async def _defer(self, *args, **kwargs) -> None:\n        return await self._get_super(\"trigger_typing\")(*args, **kwargs)\n\n    async def _edit(self, *args, **kwargs) -> Message:\n        return await self._original_response_message.edit(*args, **kwargs)\n\n    async def delete(self, *, delay: Optional[float] = None, reason: Optional[str] = None) -> None:\n        \"\"\"|coro|\n\n        Deletes the original response message, if it exists.\n\n        Parameters\n        -----------\n        delay: Optional[:class:`float`]\n            If provided, the number of seconds to wait before deleting the message.\n        reason: Optional[:class:`str`]\n            The reason for deleting the message. Shows up on the audit log.\n        \"\"\"\n        if self._original_response_message:\n            await self._original_response_message.delete(delay=delay, reason=reason)\n\n\nif TYPE_CHECKING:\n    # This is a workaround for mypy not being able to resolve the type of BridgeCommand.\n    class BridgeContext(ApplicationContext, Context):\n        ...\n", "path": "discord/ext/bridge/context.py"}], "after_files": [{"content": "\"\"\"\nThe MIT License (MIT)\n\nCopyright (c) 2015-2021 Rapptz\nCopyright (c) 2021-present Pycord Development\n\nPermission is hereby granted, free of charge, to any person obtaining a\ncopy of this software and associated documentation files (the \"Software\"),\nto deal in the Software without restriction, including without limitation\nthe rights to use, copy, modify, merge, publish, distribute, sublicense,\nand/or sell copies of the Software, and to permit persons to whom the\nSoftware is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\nOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\nFROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\nDEALINGS IN THE SOFTWARE.\n\"\"\"\nfrom abc import ABC, abstractmethod\nfrom typing import TYPE_CHECKING, Any, Optional, Union\n\nfrom discord.commands import ApplicationContext\nfrom discord.interactions import Interaction, InteractionMessage\nfrom discord.message import Message\nfrom discord.webhook import WebhookMessage\n\nfrom ..commands import Context\n\n__all__ = (\"BridgeContext\", \"BridgeExtContext\", \"BridgeApplicationContext\")\n\n\nclass BridgeContext(ABC):\n    \"\"\"\n    The base context class for compatibility commands. This class is an :class:`ABC` (abstract base class), which is\n    subclassed by :class:`BridgeExtContext` and :class:`BridgeApplicationContext`. The methods in this class are meant\n    to give parity between the two contexts, while still allowing for all of their functionality.\n\n    When this is passed to a command, it will either be passed as :class:`BridgeExtContext`, or\n    :class:`BridgeApplicationContext`. Since they are two separate classes, it is quite simple to use :meth:`isinstance`\n    to make different functionality for each context. For example, if you want to respond to a command with the command\n    type that it was invoked with, you can do the following:\n\n    .. code-block:: python3\n\n        @bot.bridge_command()\n        async def example(ctx: BridgeContext):\n            if isinstance(ctx, BridgeExtContext):\n                command_type = \"Traditional (prefix-based) command\"\n            elif isinstance(ctx, BridgeApplicationContext):\n                command_type = \"Application command\"\n            await ctx.send(f\"This command was invoked with a(n) {command_type}.\")\n\n    .. versionadded:: 2.0\n    \"\"\"\n\n    @abstractmethod\n    async def _respond(self, *args, **kwargs) -> Union[Union[Interaction, WebhookMessage], Message]:\n        ...\n\n    @abstractmethod\n    async def _defer(self, *args, **kwargs) -> None:\n        ...\n\n    @abstractmethod\n    async def _edit(self, *args, **kwargs) -> Union[InteractionMessage, Message]:\n        ...\n\n    async def respond(self, *args, **kwargs) -> Union[Union[Interaction, WebhookMessage], Message]:\n        \"\"\"|coro|\n\n        Responds to the command with the respective response type to the current context. In :class:`BridgeExtContext`,\n        this will be :meth:`~.ExtContext.reply` while in :class:`BridgeApplicationContext`, this will be\n        :meth:`~.ApplicationContext.respond`.\n        \"\"\"\n        return await self._respond(*args, **kwargs)\n\n    async def reply(self, *args, **kwargs) -> Union[Union[Interaction, WebhookMessage], Message]:\n        \"\"\"|coro|\n\n        Alias for :meth:`~.BridgeContext.respond`.\n        \"\"\"\n        return await self.respond(*args, **kwargs)\n\n    async def defer(self, *args, **kwargs) -> None:\n        \"\"\"|coro|\n\n        Defers the command with the respective approach to the current context. In :class:`BridgeExtContext`, this will\n        be :meth:`~.ExtContext.trigger_typing` while in :class:`BridgeApplicationContext`, this will be\n        :meth:`~.ApplicationContext.defer`.\n\n        .. note::\n            There is no ``trigger_typing`` alias for this method. ``trigger_typing`` will always provide the same\n            functionality across contexts.\n        \"\"\"\n        return await self._defer(*args, **kwargs)\n\n    async def edit(self, *args, **kwargs) -> Union[InteractionMessage, Message]:\n        \"\"\"|coro|\n\n        Edits the original response message with the respective approach to the current context. In\n        :class:`BridgeExtContext`, this will have a custom approach where :meth:`.respond` caches the message to be\n        edited here. In :class:`BridgeApplicationContext`, this will be :meth:`~.ApplicationContext.edit`.\n        \"\"\"\n        return await self._edit(*args, **kwargs)\n\n    def _get_super(self, attr: str) -> Optional[Any]:\n        return getattr(super(), attr)\n\n\nclass BridgeApplicationContext(BridgeContext, ApplicationContext):\n    \"\"\"\n    The application context class for compatibility commands. This class is a subclass of :class:`BridgeContext` and\n    :class:`ApplicationContext`. This class is meant to be used with :class:`BridgeCommand`.\n\n    .. versionadded:: 2.0\n    \"\"\"\n\n    async def _respond(self, *args, **kwargs) -> Union[Interaction, WebhookMessage]:\n        return await self._get_super(\"respond\")(*args, **kwargs)\n\n    async def _defer(self, *args, **kwargs) -> None:\n        return await self._get_super(\"defer\")(*args, **kwargs)\n\n    async def _edit(self, *args, **kwargs) -> InteractionMessage:\n        return await self._get_super(\"edit\")(*args, **kwargs)\n\n\nclass BridgeExtContext(BridgeContext, Context):\n    \"\"\"\n    The ext.commands context class for compatibility commands. This class is a subclass of :class:`BridgeContext` and\n    :class:`Context`. This class is meant to be used with :class:`BridgeCommand`.\n\n    .. versionadded:: 2.0\n    \"\"\"\n\n    def __init__(self, *args, **kwargs):\n        super().__init__(*args, **kwargs)\n        self._original_response_message: Optional[Message] = None\n\n    async def _respond(self, *args, **kwargs) -> Message:\n        kwargs.pop(\"ephemeral\", None)\n        message = await self._get_super(\"reply\")(*args, **kwargs)\n        if self._original_response_message is None:\n            self._original_response_message = message\n        return message\n\n    async def _defer(self, *args, **kwargs) -> None:\n        kwargs.pop(\"ephemeral\", None)\n        return await self._get_super(\"trigger_typing\")(*args, **kwargs)\n\n    async def _edit(self, *args, **kwargs) -> Message:\n        return await self._original_response_message.edit(*args, **kwargs)\n\n    async def delete(self, *, delay: Optional[float] = None, reason: Optional[str] = None) -> None:\n        \"\"\"|coro|\n\n        Deletes the original response message, if it exists.\n\n        Parameters\n        -----------\n        delay: Optional[:class:`float`]\n            If provided, the number of seconds to wait before deleting the message.\n        reason: Optional[:class:`str`]\n            The reason for deleting the message. Shows up on the audit log.\n        \"\"\"\n        if self._original_response_message:\n            await self._original_response_message.delete(delay=delay, reason=reason)\n\n\nif TYPE_CHECKING:\n    # This is a workaround for mypy not being able to resolve the type of BridgeCommand.\n    class BridgeContext(ApplicationContext, Context):\n        ...\n", "path": "discord/ext/bridge/context.py"}]}