Refactor ContextMenu constructor to allow app command type inferring

This commit is contained in:
Rapptz
2022-03-25 09:11:11 -04:00
parent cda1f0a4ef
commit 985f5732c0
2 changed files with 12 additions and 21 deletions

View File

@ -826,7 +826,8 @@ class CommandTree(Generic[ClientT]):
if not inspect.iscoroutinefunction(func):
raise TypeError('context menu function must be a coroutine function')
context_menu = ContextMenu._from_decorator(func, name=name)
actual_name = func.__name__.title() if name is MISSING else name
context_menu = ContextMenu(name=actual_name, callback=func)
self.add_command(context_menu, guild=guild, guilds=guilds)
return context_menu