aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Law <[email protected]>2021-03-24 05:22:50 -0700
committerGitHub <[email protected]>2021-03-24 08:22:50 -0400
commita06d00f554a8f7493bfad13041c0e00231502af6 (patch)
treeae0fe7f06fbcd8ce30d1f3693ffc2e07737d0041
parentUpdate create_dm documentation to say it's a coroutine (diff)
downloaddiscord.py-a06d00f554a8f7493bfad13041c0e00231502af6.tar.xz
discord.py-a06d00f554a8f7493bfad13041c0e00231502af6.zip
Make `await` text appear in async Member method docs
-rw-r--r--discord/member.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/discord/member.py b/discord/member.py
index 8e98db6a..0b6ef323 100644
--- a/discord/member.py
+++ b/discord/member.py
@@ -24,6 +24,7 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
"""
+import inspect
import itertools
import sys
from operator import attrgetter
@@ -106,8 +107,13 @@ def flatten_user(cls):
# It probably breaks something in Sphinx.
# probably a member function by now
def generate_function(x):
- def general(self, *args, **kwargs):
- return getattr(self._user, x)(*args, **kwargs)
+ # We want sphinx to properly show coroutine functions as coroutines
+ if inspect.iscoroutinefunction(value):
+ async def general(self, *args, **kwargs):
+ return await getattr(self._user, x)(*args, **kwargs)
+ else:
+ def general(self, *args, **kwargs):
+ return getattr(self._user, x)(*args, **kwargs)
general.__name__ = x
return general