mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 19:28:54 -05:00
[Utils] Allow functools.partial use with menu (#2720)
This commit is contained in:
parent
1cfce8b72c
commit
0a832cee9c
@ -4,6 +4,7 @@
|
|||||||
# Ported to Red V3 by Palm\_\_ (https://github.com/palmtree5)
|
# Ported to Red V3 by Palm\_\_ (https://github.com/palmtree5)
|
||||||
import asyncio
|
import asyncio
|
||||||
import contextlib
|
import contextlib
|
||||||
|
import functools
|
||||||
from typing import Union, Iterable, Optional
|
from typing import Union, Iterable, Optional
|
||||||
import discord
|
import discord
|
||||||
|
|
||||||
@ -60,7 +61,10 @@ async def menu(
|
|||||||
):
|
):
|
||||||
raise RuntimeError("All pages must be of the same type")
|
raise RuntimeError("All pages must be of the same type")
|
||||||
for key, value in controls.items():
|
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")
|
raise RuntimeError("Function must be a coroutine")
|
||||||
current_page = pages[page]
|
current_page = pages[page]
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user