From 0a832cee9cd6f44afc3fec38bc63ea63cdf0acb2 Mon Sep 17 00:00:00 2001 From: DiscordLiz <47602820+DiscordLiz@users.noreply.github.com> Date: Tue, 21 May 2019 16:52:44 -0400 Subject: [PATCH] [Utils] Allow functools.partial use with menu (#2720) --- redbot/core/utils/menus.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/redbot/core/utils/menus.py b/redbot/core/utils/menus.py index b60929e09..6305b19ff 100644 --- a/redbot/core/utils/menus.py +++ b/redbot/core/utils/menus.py @@ -4,6 +4,7 @@ # Ported to Red V3 by Palm\_\_ (https://github.com/palmtree5) import asyncio import contextlib +import functools from typing import Union, Iterable, Optional import discord @@ -60,7 +61,10 @@ async def menu( ): raise RuntimeError("All pages must be of the same type") for key, value in controls.items(): - if not asyncio.iscoroutinefunction(value): + maybe_coro = value + if isinstance(value, functools.partial): + maybe_coro = value.func + if not asyncio.iscoroutinefunction(maybe_coro): raise RuntimeError("Function must be a coroutine") current_page = pages[page]