We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Context.channel
### Summary

The type for [Context.channel](https://discordpy.readthedocs.io/en/latest/api.html?highlight=message%20channel#discord.Message.channel) seems to be incorrect in the doc

### Reproduction Steps

See [Context.channel](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html?highlight=context%20channel#discord.ext.commands.Context.channel)

The type shown here is `TextChannel`, although this could also be a `DMChannel`.

### Expected Results

The type for Context.channel should be the same as [Message.channel](https://discordpy.readthedocs.io/en/latest/api.html?highlight=message%20channel#discord.Message.channel) which is `Union[abc.Messageable]`


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

I was unsure which template to use, so I picked this one.

--- 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/commands/context.py`
Content:
```
1 # -*- coding: utf-8 -*-
2 
3 """
4 The MIT License (MIT)
5 
6 Copyright (c) 2015-present Rapptz
7 
8 Permission is hereby granted, free of charge, to any person obtaining a
9 copy of this software and associated documentation files (the "Software"),
10 to deal in the Software without restriction, including without limitation
11 the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 and/or sell copies of the Software, and to permit persons to whom the
13 Software is furnished to do so, subject to the following conditions:
14 
15 The above copyright notice and this permission notice shall be included in
16 all copies or substantial portions of the Software.
17 
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24 DEALINGS IN THE SOFTWARE.
25 """
26 
27 import discord.abc
28 import discord.utils
29 
30 class Context(discord.abc.Messageable):
31     r"""Represents the context in which a command is being invoked under.
32 
33     This class contains a lot of meta data to help you understand more about
34     the invocation context. This class is not created manually and is instead
35     passed around to commands as the first parameter.
36 
37     This class implements the :class:`~discord.abc.Messageable` ABC.
38 
39     Attributes
40     -----------
41     message: :class:`.Message`
42         The message that triggered the command being executed.
43     bot: :class:`.Bot`
44         The bot that contains the command being executed.
45     args: :class:`list`
46         The list of transformed arguments that were passed into the command.
47         If this is accessed during the :func:`on_command_error` event
48         then this list could be incomplete.
49     kwargs: :class:`dict`
50         A dictionary of transformed arguments that were passed into the command.
51         Similar to :attr:`args`\, if this is accessed in the
52         :func:`on_command_error` event then this dict could be incomplete.
53     prefix: :class:`str`
54         The prefix that was used to invoke the command.
55     command: :class:`Command`
56         The command that is being invoked currently.
57     invoked_with: :class:`str`
58         The command name that triggered this invocation. Useful for finding out
59         which alias called the command.
60     invoked_parents: List[:class:`str`]
61         The command names of the parents that triggered this invocation. Useful for
62         finding out which aliases called the command.
63 
64         For example in commands ``?a b c test``, the invoked parents are ``['a', 'b', 'c']``.
65 
66         .. versionadded:: 1.7
67 
68     invoked_subcommand: :class:`Command`
69         The subcommand that was invoked.
70         If no valid subcommand was invoked then this is equal to ``None``.
71     subcommand_passed: Optional[:class:`str`]
72         The string that was attempted to call a subcommand. This does not have
73         to point to a valid registered subcommand and could just point to a
74         nonsense string. If nothing was passed to attempt a call to a
75         subcommand then this is set to ``None``.
76     command_failed: :class:`bool`
77         A boolean that indicates if the command failed to be parsed, checked,
78         or invoked.
79     """
80 
81     def __init__(self, **attrs):
82         self.message = attrs.pop('message', None)
83         self.bot = attrs.pop('bot', None)
84         self.args = attrs.pop('args', [])
85         self.kwargs = attrs.pop('kwargs', {})
86         self.prefix = attrs.pop('prefix')
87         self.command = attrs.pop('command', None)
88         self.view = attrs.pop('view', None)
89         self.invoked_with = attrs.pop('invoked_with', None)
90         self.invoked_parents = attrs.pop('invoked_parents', [])
91         self.invoked_subcommand = attrs.pop('invoked_subcommand', None)
92         self.subcommand_passed = attrs.pop('subcommand_passed', None)
93         self.command_failed = attrs.pop('command_failed', False)
94         self._state = self.message._state
95 
96     async def invoke(self, *args, **kwargs):
97         r"""|coro|
98 
99         Calls a command with the arguments given.
100 
101         This is useful if you want to just call the callback that a
102         :class:`.Command` holds internally.
103 
104         .. note::
105 
106             This does not handle converters, checks, cooldowns, pre-invoke,
107             or after-invoke hooks in any matter. It calls the internal callback
108             directly as-if it was a regular function.
109 
110             You must take care in passing the proper arguments when
111             using this function.
112 
113         .. warning::
114 
115             The first parameter passed **must** be the command being invoked.
116 
117         Parameters
118         -----------
119         command: :class:`.Command`
120             The command that is going to be called.
121         \*args
122             The arguments to to use.
123         \*\*kwargs
124             The keyword arguments to use.
125 
126         Raises
127         -------
128         TypeError
129             The command argument to invoke is missing.
130         """
131 
132         try:
133             command = args[0]
134         except IndexError:
135             raise TypeError('Missing command to invoke.') from None
136 
137         arguments = []
138         if command.cog is not None:
139             arguments.append(command.cog)
140 
141         arguments.append(self)
142         arguments.extend(args[1:])
143 
144         ret = await command.callback(*arguments, **kwargs)
145         return ret
146 
147     async def reinvoke(self, *, call_hooks=False, restart=True):
148         """|coro|
149 
150         Calls the command again.
151 
152         This is similar to :meth:`~.Context.invoke` except that it bypasses
153         checks, cooldowns, and error handlers.
154 
155         .. note::
156 
157             If you want to bypass :exc:`.UserInputError` derived exceptions,
158             it is recommended to use the regular :meth:`~.Context.invoke`
159             as it will work more naturally. After all, this will end up
160             using the old arguments the user has used and will thus just
161             fail again.
162 
163         Parameters
164         ------------
165         call_hooks: :class:`bool`
166             Whether to call the before and after invoke hooks.
167         restart: :class:`bool`
168             Whether to start the call chain from the very beginning
169             or where we left off (i.e. the command that caused the error).
170             The default is to start where we left off.
171 
172         Raises
173         -------
174         ValueError
175             The context to reinvoke is not valid.
176         """
177         cmd = self.command
178         view = self.view
179         if cmd is None:
180             raise ValueError('This context is not valid.')
181 
182         # some state to revert to when we're done
183         index, previous = view.index, view.previous
184         invoked_with = self.invoked_with
185         invoked_subcommand = self.invoked_subcommand
186         invoked_parents = self.invoked_parents
187         subcommand_passed = self.subcommand_passed
188 
189         if restart:
190             to_call = cmd.root_parent or cmd
191             view.index = len(self.prefix)
192             view.previous = 0
193             self.invoked_parents = []
194             self.invoked_with = view.get_word() # advance to get the root command
195         else:
196             to_call = cmd
197 
198         try:
199             await to_call.reinvoke(self, call_hooks=call_hooks)
200         finally:
201             self.command = cmd
202             view.index = index
203             view.previous = previous
204             self.invoked_with = invoked_with
205             self.invoked_subcommand = invoked_subcommand
206             self.invoked_parents = invoked_parents
207             self.subcommand_passed = subcommand_passed
208 
209     @property
210     def valid(self):
211         """:class:`bool`: Checks if the invocation context is valid to be invoked with."""
212         return self.prefix is not None and self.command is not None
213 
214     async def _get_channel(self):
215         return self.channel
216 
217     @property
218     def cog(self):
219         """Optional[:class:`.Cog`]: Returns the cog associated with this context's command. None if it does not exist."""
220 
221         if self.command is None:
222             return None
223         return self.command.cog
224 
225     @discord.utils.cached_property
226     def guild(self):
227         """Optional[:class:`.Guild`]: Returns the guild associated with this context's command. None if not available."""
228         return self.message.guild
229 
230     @discord.utils.cached_property
231     def channel(self):
232         """:class:`.TextChannel`:
233         Returns the channel associated with this context's command. Shorthand for :attr:`.Message.channel`.
234         """
235         return self.message.channel
236 
237     @discord.utils.cached_property
238     def author(self):
239         """Union[:class:`~discord.User`, :class:`.Member`]:
240         Returns the author associated with this context's command. Shorthand for :attr:`.Message.author`
241         """
242         return self.message.author
243 
244     @discord.utils.cached_property
245     def me(self):
246         """Union[:class:`.Member`, :class:`.ClientUser`]:
247         Similar to :attr:`.Guild.me` except it may return the :class:`.ClientUser` in private message contexts.
248         """
249         return self.guild.me if self.guild is not None else self.bot.user
250 
251     @property
252     def voice_client(self):
253         r"""Optional[:class:`.VoiceProtocol`]: A shortcut to :attr:`.Guild.voice_client`\, if applicable."""
254         g = self.guild
255         return g.voice_client if g else None
256 
257     async def send_help(self, *args):
258         """send_help(entity=<bot>)
259 
260         |coro|
261 
262         Shows the help command for the specified entity if given.
263         The entity can be a command or a cog.
264 
265         If no entity is given, then it'll show help for the
266         entire bot.
267 
268         If the entity is a string, then it looks up whether it's a
269         :class:`Cog` or a :class:`Command`.
270 
271         .. note::
272 
273             Due to the way this function works, instead of returning
274             something similar to :meth:`~.commands.HelpCommand.command_not_found`
275             this returns :class:`None` on bad input or no help command.
276 
277         Parameters
278         ------------
279         entity: Optional[Union[:class:`Command`, :class:`Cog`, :class:`str`]]
280             The entity to show help for.
281 
282         Returns
283         --------
284         Any
285             The result of the help command, if any.
286         """
287         from .core import Group, Command, wrap_callback
288         from .errors import CommandError
289 
290         bot = self.bot
291         cmd = bot.help_command
292 
293         if cmd is None:
294             return None
295 
296         cmd = cmd.copy()
297         cmd.context = self
298         if len(args) == 0:
299             await cmd.prepare_help_command(self, None)
300             mapping = cmd.get_bot_mapping()
301             injected = wrap_callback(cmd.send_bot_help)
302             try:
303                 return await injected(mapping)
304             except CommandError as e:
305                 await cmd.on_help_command_error(self, e)
306                 return None
307 
308         entity = args[0]
309         if entity is None:
310             return None
311 
312         if isinstance(entity, str):
313             entity = bot.get_cog(entity) or bot.get_command(entity)
314 
315         try:
316             entity.qualified_name
317         except AttributeError:
318             # if we're here then it's not a cog, group, or command.
319             return None
320 
321         await cmd.prepare_help_command(self, entity.qualified_name)
322 
323         try:
324             if hasattr(entity, '__cog_commands__'):
325                 injected = wrap_callback(cmd.send_cog_help)
326                 return await injected(entity)
327             elif isinstance(entity, Group):
328                 injected = wrap_callback(cmd.send_group_help)
329                 return await injected(entity)
330             elif isinstance(entity, Command):
331                 injected = wrap_callback(cmd.send_command_help)
332                 return await injected(entity)
333             else:
334                 return None
335         except CommandError as e:
336             await cmd.on_help_command_error(self, e)
337 
338     async def reply(self, content=None, **kwargs):
339         return await self.message.reply(content, **kwargs)
340 
341     reply.__doc__ = discord.Message.reply.__doc__
342
```
--- 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/commands/context.py b/discord/ext/commands/context.py
--- a/discord/ext/commands/context.py
+++ b/discord/ext/commands/context.py
@@ -229,8 +229,8 @@
 
     @discord.utils.cached_property
     def channel(self):
-        """:class:`.TextChannel`:
-        Returns the channel associated with this context's command. Shorthand for :attr:`.Message.channel`.
+        """Union[:class:`.abc.Messageable`]: Returns the channel associated with this context's command.
+        Shorthand for :attr:`.Message.channel`.
         """
         return self.message.channel

{"golden_diff": "diff --git a/discord/ext/commands/context.py b/discord/ext/commands/context.py\n--- a/discord/ext/commands/context.py\n+++ b/discord/ext/commands/context.py\n@@ -229,8 +229,8 @@\n \n     @discord.utils.cached_property\n     def channel(self):\n-        \"\"\":class:`.TextChannel`:\n-        Returns the channel associated with this context's command. Shorthand for :attr:`.Message.channel`.\n+        \"\"\"Union[:class:`.abc.Messageable`]: Returns the channel associated with this context's command.\n+        Shorthand for :attr:`.Message.channel`.\n         \"\"\"\n         return self.message.channel\n", "issue": "Context.channel\n### Summary\r\n\r\nThe type for [Context.channel](https://discordpy.readthedocs.io/en/latest/api.html?highlight=message%20channel#discord.Message.channel) seems to be incorrect in the doc\r\n\r\n### Reproduction Steps\r\n\r\nSee [Context.channel](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html?highlight=context%20channel#discord.ext.commands.Context.channel)\r\n\r\nThe type shown here is `TextChannel`, although this could also be a `DMChannel`.\r\n\r\n### Expected Results\r\n\r\nThe type for Context.channel should be the same as [Message.channel](https://discordpy.readthedocs.io/en/latest/api.html?highlight=message%20channel#discord.Message.channel) which is `Union[abc.Messageable]`\r\n\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\nI was unsure which template to use, so I picked this one.\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n\n\"\"\"\nThe MIT License (MIT)\n\nCopyright (c) 2015-present Rapptz\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\"\"\"\n\nimport discord.abc\nimport discord.utils\n\nclass Context(discord.abc.Messageable):\n    r\"\"\"Represents the context in which a command is being invoked under.\n\n    This class contains a lot of meta data to help you understand more about\n    the invocation context. This class is not created manually and is instead\n    passed around to commands as the first parameter.\n\n    This class implements the :class:`~discord.abc.Messageable` ABC.\n\n    Attributes\n    -----------\n    message: :class:`.Message`\n        The message that triggered the command being executed.\n    bot: :class:`.Bot`\n        The bot that contains the command being executed.\n    args: :class:`list`\n        The list of transformed arguments that were passed into the command.\n        If this is accessed during the :func:`on_command_error` event\n        then this list could be incomplete.\n    kwargs: :class:`dict`\n        A dictionary of transformed arguments that were passed into the command.\n        Similar to :attr:`args`\\, if this is accessed in the\n        :func:`on_command_error` event then this dict could be incomplete.\n    prefix: :class:`str`\n        The prefix that was used to invoke the command.\n    command: :class:`Command`\n        The command that is being invoked currently.\n    invoked_with: :class:`str`\n        The command name that triggered this invocation. Useful for finding out\n        which alias called the command.\n    invoked_parents: List[:class:`str`]\n        The command names of the parents that triggered this invocation. Useful for\n        finding out which aliases called the command.\n\n        For example in commands ``?a b c test``, the invoked parents are ``['a', 'b', 'c']``.\n\n        .. versionadded:: 1.7\n\n    invoked_subcommand: :class:`Command`\n        The subcommand that was invoked.\n        If no valid subcommand was invoked then this is equal to ``None``.\n    subcommand_passed: Optional[:class:`str`]\n        The string that was attempted to call a subcommand. This does not have\n        to point to a valid registered subcommand and could just point to a\n        nonsense string. If nothing was passed to attempt a call to a\n        subcommand then this is set to ``None``.\n    command_failed: :class:`bool`\n        A boolean that indicates if the command failed to be parsed, checked,\n        or invoked.\n    \"\"\"\n\n    def __init__(self, **attrs):\n        self.message = attrs.pop('message', None)\n        self.bot = attrs.pop('bot', None)\n        self.args = attrs.pop('args', [])\n        self.kwargs = attrs.pop('kwargs', {})\n        self.prefix = attrs.pop('prefix')\n        self.command = attrs.pop('command', None)\n        self.view = attrs.pop('view', None)\n        self.invoked_with = attrs.pop('invoked_with', None)\n        self.invoked_parents = attrs.pop('invoked_parents', [])\n        self.invoked_subcommand = attrs.pop('invoked_subcommand', None)\n        self.subcommand_passed = attrs.pop('subcommand_passed', None)\n        self.command_failed = attrs.pop('command_failed', False)\n        self._state = self.message._state\n\n    async def invoke(self, *args, **kwargs):\n        r\"\"\"|coro|\n\n        Calls a command with the arguments given.\n\n        This is useful if you want to just call the callback that a\n        :class:`.Command` holds internally.\n\n        .. note::\n\n            This does not handle converters, checks, cooldowns, pre-invoke,\n            or after-invoke hooks in any matter. It calls the internal callback\n            directly as-if it was a regular function.\n\n            You must take care in passing the proper arguments when\n            using this function.\n\n        .. warning::\n\n            The first parameter passed **must** be the command being invoked.\n\n        Parameters\n        -----------\n        command: :class:`.Command`\n            The command that is going to be called.\n        \\*args\n            The arguments to to use.\n        \\*\\*kwargs\n            The keyword arguments to use.\n\n        Raises\n        -------\n        TypeError\n            The command argument to invoke is missing.\n        \"\"\"\n\n        try:\n            command = args[0]\n        except IndexError:\n            raise TypeError('Missing command to invoke.') from None\n\n        arguments = []\n        if command.cog is not None:\n            arguments.append(command.cog)\n\n        arguments.append(self)\n        arguments.extend(args[1:])\n\n        ret = await command.callback(*arguments, **kwargs)\n        return ret\n\n    async def reinvoke(self, *, call_hooks=False, restart=True):\n        \"\"\"|coro|\n\n        Calls the command again.\n\n        This is similar to :meth:`~.Context.invoke` except that it bypasses\n        checks, cooldowns, and error handlers.\n\n        .. note::\n\n            If you want to bypass :exc:`.UserInputError` derived exceptions,\n            it is recommended to use the regular :meth:`~.Context.invoke`\n            as it will work more naturally. After all, this will end up\n            using the old arguments the user has used and will thus just\n            fail again.\n\n        Parameters\n        ------------\n        call_hooks: :class:`bool`\n            Whether to call the before and after invoke hooks.\n        restart: :class:`bool`\n            Whether to start the call chain from the very beginning\n            or where we left off (i.e. the command that caused the error).\n            The default is to start where we left off.\n\n        Raises\n        -------\n        ValueError\n            The context to reinvoke is not valid.\n        \"\"\"\n        cmd = self.command\n        view = self.view\n        if cmd is None:\n            raise ValueError('This context is not valid.')\n\n        # some state to revert to when we're done\n        index, previous = view.index, view.previous\n        invoked_with = self.invoked_with\n        invoked_subcommand = self.invoked_subcommand\n        invoked_parents = self.invoked_parents\n        subcommand_passed = self.subcommand_passed\n\n        if restart:\n            to_call = cmd.root_parent or cmd\n            view.index = len(self.prefix)\n            view.previous = 0\n            self.invoked_parents = []\n            self.invoked_with = view.get_word() # advance to get the root command\n        else:\n            to_call = cmd\n\n        try:\n            await to_call.reinvoke(self, call_hooks=call_hooks)\n        finally:\n            self.command = cmd\n            view.index = index\n            view.previous = previous\n            self.invoked_with = invoked_with\n            self.invoked_subcommand = invoked_subcommand\n            self.invoked_parents = invoked_parents\n            self.subcommand_passed = subcommand_passed\n\n    @property\n    def valid(self):\n        \"\"\":class:`bool`: Checks if the invocation context is valid to be invoked with.\"\"\"\n        return self.prefix is not None and self.command is not None\n\n    async def _get_channel(self):\n        return self.channel\n\n    @property\n    def cog(self):\n        \"\"\"Optional[:class:`.Cog`]: Returns the cog associated with this context's command. None if it does not exist.\"\"\"\n\n        if self.command is None:\n            return None\n        return self.command.cog\n\n    @discord.utils.cached_property\n    def guild(self):\n        \"\"\"Optional[:class:`.Guild`]: Returns the guild associated with this context's command. None if not available.\"\"\"\n        return self.message.guild\n\n    @discord.utils.cached_property\n    def channel(self):\n        \"\"\":class:`.TextChannel`:\n        Returns the channel associated with this context's command. Shorthand for :attr:`.Message.channel`.\n        \"\"\"\n        return self.message.channel\n\n    @discord.utils.cached_property\n    def author(self):\n        \"\"\"Union[:class:`~discord.User`, :class:`.Member`]:\n        Returns the author associated with this context's command. Shorthand for :attr:`.Message.author`\n        \"\"\"\n        return self.message.author\n\n    @discord.utils.cached_property\n    def me(self):\n        \"\"\"Union[:class:`.Member`, :class:`.ClientUser`]:\n        Similar to :attr:`.Guild.me` except it may return the :class:`.ClientUser` in private message contexts.\n        \"\"\"\n        return self.guild.me if self.guild is not None else self.bot.user\n\n    @property\n    def voice_client(self):\n        r\"\"\"Optional[:class:`.VoiceProtocol`]: A shortcut to :attr:`.Guild.voice_client`\\, if applicable.\"\"\"\n        g = self.guild\n        return g.voice_client if g else None\n\n    async def send_help(self, *args):\n        \"\"\"send_help(entity=<bot>)\n\n        |coro|\n\n        Shows the help command for the specified entity if given.\n        The entity can be a command or a cog.\n\n        If no entity is given, then it'll show help for the\n        entire bot.\n\n        If the entity is a string, then it looks up whether it's a\n        :class:`Cog` or a :class:`Command`.\n\n        .. note::\n\n            Due to the way this function works, instead of returning\n            something similar to :meth:`~.commands.HelpCommand.command_not_found`\n            this returns :class:`None` on bad input or no help command.\n\n        Parameters\n        ------------\n        entity: Optional[Union[:class:`Command`, :class:`Cog`, :class:`str`]]\n            The entity to show help for.\n\n        Returns\n        --------\n        Any\n            The result of the help command, if any.\n        \"\"\"\n        from .core import Group, Command, wrap_callback\n        from .errors import CommandError\n\n        bot = self.bot\n        cmd = bot.help_command\n\n        if cmd is None:\n            return None\n\n        cmd = cmd.copy()\n        cmd.context = self\n        if len(args) == 0:\n            await cmd.prepare_help_command(self, None)\n            mapping = cmd.get_bot_mapping()\n            injected = wrap_callback(cmd.send_bot_help)\n            try:\n                return await injected(mapping)\n            except CommandError as e:\n                await cmd.on_help_command_error(self, e)\n                return None\n\n        entity = args[0]\n        if entity is None:\n            return None\n\n        if isinstance(entity, str):\n            entity = bot.get_cog(entity) or bot.get_command(entity)\n\n        try:\n            entity.qualified_name\n        except AttributeError:\n            # if we're here then it's not a cog, group, or command.\n            return None\n\n        await cmd.prepare_help_command(self, entity.qualified_name)\n\n        try:\n            if hasattr(entity, '__cog_commands__'):\n                injected = wrap_callback(cmd.send_cog_help)\n                return await injected(entity)\n            elif isinstance(entity, Group):\n                injected = wrap_callback(cmd.send_group_help)\n                return await injected(entity)\n            elif isinstance(entity, Command):\n                injected = wrap_callback(cmd.send_command_help)\n                return await injected(entity)\n            else:\n                return None\n        except CommandError as e:\n            await cmd.on_help_command_error(self, e)\n\n    async def reply(self, content=None, **kwargs):\n        return await self.message.reply(content, **kwargs)\n\n    reply.__doc__ = discord.Message.reply.__doc__\n", "path": "discord/ext/commands/context.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n\n\"\"\"\nThe MIT License (MIT)\n\nCopyright (c) 2015-present Rapptz\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\"\"\"\n\nimport discord.abc\nimport discord.utils\n\nclass Context(discord.abc.Messageable):\n    r\"\"\"Represents the context in which a command is being invoked under.\n\n    This class contains a lot of meta data to help you understand more about\n    the invocation context. This class is not created manually and is instead\n    passed around to commands as the first parameter.\n\n    This class implements the :class:`~discord.abc.Messageable` ABC.\n\n    Attributes\n    -----------\n    message: :class:`.Message`\n        The message that triggered the command being executed.\n    bot: :class:`.Bot`\n        The bot that contains the command being executed.\n    args: :class:`list`\n        The list of transformed arguments that were passed into the command.\n        If this is accessed during the :func:`on_command_error` event\n        then this list could be incomplete.\n    kwargs: :class:`dict`\n        A dictionary of transformed arguments that were passed into the command.\n        Similar to :attr:`args`\\, if this is accessed in the\n        :func:`on_command_error` event then this dict could be incomplete.\n    prefix: :class:`str`\n        The prefix that was used to invoke the command.\n    command: :class:`Command`\n        The command that is being invoked currently.\n    invoked_with: :class:`str`\n        The command name that triggered this invocation. Useful for finding out\n        which alias called the command.\n    invoked_parents: List[:class:`str`]\n        The command names of the parents that triggered this invocation. Useful for\n        finding out which aliases called the command.\n\n        For example in commands ``?a b c test``, the invoked parents are ``['a', 'b', 'c']``.\n\n        .. versionadded:: 1.7\n\n    invoked_subcommand: :class:`Command`\n        The subcommand that was invoked.\n        If no valid subcommand was invoked then this is equal to ``None``.\n    subcommand_passed: Optional[:class:`str`]\n        The string that was attempted to call a subcommand. This does not have\n        to point to a valid registered subcommand and could just point to a\n        nonsense string. If nothing was passed to attempt a call to a\n        subcommand then this is set to ``None``.\n    command_failed: :class:`bool`\n        A boolean that indicates if the command failed to be parsed, checked,\n        or invoked.\n    \"\"\"\n\n    def __init__(self, **attrs):\n        self.message = attrs.pop('message', None)\n        self.bot = attrs.pop('bot', None)\n        self.args = attrs.pop('args', [])\n        self.kwargs = attrs.pop('kwargs', {})\n        self.prefix = attrs.pop('prefix')\n        self.command = attrs.pop('command', None)\n        self.view = attrs.pop('view', None)\n        self.invoked_with = attrs.pop('invoked_with', None)\n        self.invoked_parents = attrs.pop('invoked_parents', [])\n        self.invoked_subcommand = attrs.pop('invoked_subcommand', None)\n        self.subcommand_passed = attrs.pop('subcommand_passed', None)\n        self.command_failed = attrs.pop('command_failed', False)\n        self._state = self.message._state\n\n    async def invoke(self, *args, **kwargs):\n        r\"\"\"|coro|\n\n        Calls a command with the arguments given.\n\n        This is useful if you want to just call the callback that a\n        :class:`.Command` holds internally.\n\n        .. note::\n\n            This does not handle converters, checks, cooldowns, pre-invoke,\n            or after-invoke hooks in any matter. It calls the internal callback\n            directly as-if it was a regular function.\n\n            You must take care in passing the proper arguments when\n            using this function.\n\n        .. warning::\n\n            The first parameter passed **must** be the command being invoked.\n\n        Parameters\n        -----------\n        command: :class:`.Command`\n            The command that is going to be called.\n        \\*args\n            The arguments to to use.\n        \\*\\*kwargs\n            The keyword arguments to use.\n\n        Raises\n        -------\n        TypeError\n            The command argument to invoke is missing.\n        \"\"\"\n\n        try:\n            command = args[0]\n        except IndexError:\n            raise TypeError('Missing command to invoke.') from None\n\n        arguments = []\n        if command.cog is not None:\n            arguments.append(command.cog)\n\n        arguments.append(self)\n        arguments.extend(args[1:])\n\n        ret = await command.callback(*arguments, **kwargs)\n        return ret\n\n    async def reinvoke(self, *, call_hooks=False, restart=True):\n        \"\"\"|coro|\n\n        Calls the command again.\n\n        This is similar to :meth:`~.Context.invoke` except that it bypasses\n        checks, cooldowns, and error handlers.\n\n        .. note::\n\n            If you want to bypass :exc:`.UserInputError` derived exceptions,\n            it is recommended to use the regular :meth:`~.Context.invoke`\n            as it will work more naturally. After all, this will end up\n            using the old arguments the user has used and will thus just\n            fail again.\n\n        Parameters\n        ------------\n        call_hooks: :class:`bool`\n            Whether to call the before and after invoke hooks.\n        restart: :class:`bool`\n            Whether to start the call chain from the very beginning\n            or where we left off (i.e. the command that caused the error).\n            The default is to start where we left off.\n\n        Raises\n        -------\n        ValueError\n            The context to reinvoke is not valid.\n        \"\"\"\n        cmd = self.command\n        view = self.view\n        if cmd is None:\n            raise ValueError('This context is not valid.')\n\n        # some state to revert to when we're done\n        index, previous = view.index, view.previous\n        invoked_with = self.invoked_with\n        invoked_subcommand = self.invoked_subcommand\n        invoked_parents = self.invoked_parents\n        subcommand_passed = self.subcommand_passed\n\n        if restart:\n            to_call = cmd.root_parent or cmd\n            view.index = len(self.prefix)\n            view.previous = 0\n            self.invoked_parents = []\n            self.invoked_with = view.get_word() # advance to get the root command\n        else:\n            to_call = cmd\n\n        try:\n            await to_call.reinvoke(self, call_hooks=call_hooks)\n        finally:\n            self.command = cmd\n            view.index = index\n            view.previous = previous\n            self.invoked_with = invoked_with\n            self.invoked_subcommand = invoked_subcommand\n            self.invoked_parents = invoked_parents\n            self.subcommand_passed = subcommand_passed\n\n    @property\n    def valid(self):\n        \"\"\":class:`bool`: Checks if the invocation context is valid to be invoked with.\"\"\"\n        return self.prefix is not None and self.command is not None\n\n    async def _get_channel(self):\n        return self.channel\n\n    @property\n    def cog(self):\n        \"\"\"Optional[:class:`.Cog`]: Returns the cog associated with this context's command. None if it does not exist.\"\"\"\n\n        if self.command is None:\n            return None\n        return self.command.cog\n\n    @discord.utils.cached_property\n    def guild(self):\n        \"\"\"Optional[:class:`.Guild`]: Returns the guild associated with this context's command. None if not available.\"\"\"\n        return self.message.guild\n\n    @discord.utils.cached_property\n    def channel(self):\n        \"\"\"Union[:class:`.abc.Messageable`]: Returns the channel associated with this context's command.\n        Shorthand for :attr:`.Message.channel`.\n        \"\"\"\n        return self.message.channel\n\n    @discord.utils.cached_property\n    def author(self):\n        \"\"\"Union[:class:`~discord.User`, :class:`.Member`]:\n        Returns the author associated with this context's command. Shorthand for :attr:`.Message.author`\n        \"\"\"\n        return self.message.author\n\n    @discord.utils.cached_property\n    def me(self):\n        \"\"\"Union[:class:`.Member`, :class:`.ClientUser`]:\n        Similar to :attr:`.Guild.me` except it may return the :class:`.ClientUser` in private message contexts.\n        \"\"\"\n        return self.guild.me if self.guild is not None else self.bot.user\n\n    @property\n    def voice_client(self):\n        r\"\"\"Optional[:class:`.VoiceProtocol`]: A shortcut to :attr:`.Guild.voice_client`\\, if applicable.\"\"\"\n        g = self.guild\n        return g.voice_client if g else None\n\n    async def send_help(self, *args):\n        \"\"\"send_help(entity=<bot>)\n\n        |coro|\n\n        Shows the help command for the specified entity if given.\n        The entity can be a command or a cog.\n\n        If no entity is given, then it'll show help for the\n        entire bot.\n\n        If the entity is a string, then it looks up whether it's a\n        :class:`Cog` or a :class:`Command`.\n\n        .. note::\n\n            Due to the way this function works, instead of returning\n            something similar to :meth:`~.commands.HelpCommand.command_not_found`\n            this returns :class:`None` on bad input or no help command.\n\n        Parameters\n        ------------\n        entity: Optional[Union[:class:`Command`, :class:`Cog`, :class:`str`]]\n            The entity to show help for.\n\n        Returns\n        --------\n        Any\n            The result of the help command, if any.\n        \"\"\"\n        from .core import Group, Command, wrap_callback\n        from .errors import CommandError\n\n        bot = self.bot\n        cmd = bot.help_command\n\n        if cmd is None:\n            return None\n\n        cmd = cmd.copy()\n        cmd.context = self\n        if len(args) == 0:\n            await cmd.prepare_help_command(self, None)\n            mapping = cmd.get_bot_mapping()\n            injected = wrap_callback(cmd.send_bot_help)\n            try:\n                return await injected(mapping)\n            except CommandError as e:\n                await cmd.on_help_command_error(self, e)\n                return None\n\n        entity = args[0]\n        if entity is None:\n            return None\n\n        if isinstance(entity, str):\n            entity = bot.get_cog(entity) or bot.get_command(entity)\n\n        try:\n            entity.qualified_name\n        except AttributeError:\n            # if we're here then it's not a cog, group, or command.\n            return None\n\n        await cmd.prepare_help_command(self, entity.qualified_name)\n\n        try:\n            if hasattr(entity, '__cog_commands__'):\n                injected = wrap_callback(cmd.send_cog_help)\n                return await injected(entity)\n            elif isinstance(entity, Group):\n                injected = wrap_callback(cmd.send_group_help)\n                return await injected(entity)\n            elif isinstance(entity, Command):\n                injected = wrap_callback(cmd.send_command_help)\n                return await injected(entity)\n            else:\n                return None\n        except CommandError as e:\n            await cmd.on_help_command_error(self, e)\n\n    async def reply(self, content=None, **kwargs):\n        return await self.message.reply(content, **kwargs)\n\n    reply.__doc__ = discord.Message.reply.__doc__\n", "path": "discord/ext/commands/context.py"}]}