mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-07-23 11:26:51 +00:00
Support app_commands.guilds decorator for context menu commands
This commit is contained in:
parent
0ef369c0fa
commit
1d1bba1f90
@ -618,6 +618,7 @@ class ContextMenu:
|
|||||||
name: str,
|
name: str,
|
||||||
callback: ContextMenuCallback,
|
callback: ContextMenuCallback,
|
||||||
type: AppCommandType,
|
type: AppCommandType,
|
||||||
|
guild_ids: Optional[List[int]] = None,
|
||||||
):
|
):
|
||||||
self.name: str = validate_context_menu_name(name)
|
self.name: str = validate_context_menu_name(name)
|
||||||
self._callback: ContextMenuCallback = callback
|
self._callback: ContextMenuCallback = callback
|
||||||
@ -628,6 +629,7 @@ class ContextMenu:
|
|||||||
self._param_name = param
|
self._param_name = param
|
||||||
self._annotation = annotation
|
self._annotation = annotation
|
||||||
self.module: Optional[str] = callback.__module__
|
self.module: Optional[str] = callback.__module__
|
||||||
|
self._guild_ids = guild_ids
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def callback(self) -> ContextMenuCallback:
|
def callback(self) -> ContextMenuCallback:
|
||||||
@ -645,6 +647,7 @@ class ContextMenu:
|
|||||||
self._param_name = param
|
self._param_name = param
|
||||||
self._annotation = annotation
|
self._annotation = annotation
|
||||||
self.module = callback.__module__
|
self.module = callback.__module__
|
||||||
|
self._guild_ids = None
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def to_dict(self) -> Dict[str, Any]:
|
def to_dict(self) -> Dict[str, Any]:
|
||||||
@ -1196,7 +1199,7 @@ def guilds(*guild_ids: Union[Snowflake, int]) -> Callable[[T], T]:
|
|||||||
defaults: List[int] = [g if isinstance(g, int) else g.id for g in guild_ids]
|
defaults: List[int] = [g if isinstance(g, int) else g.id for g in guild_ids]
|
||||||
|
|
||||||
def decorator(inner: T) -> T:
|
def decorator(inner: T) -> T:
|
||||||
if isinstance(inner, Group):
|
if isinstance(inner, (Group, ContextMenu)):
|
||||||
inner._guild_ids = defaults
|
inner._guild_ids = defaults
|
||||||
elif isinstance(inner, Command):
|
elif isinstance(inner, Command):
|
||||||
if inner.parent is not None:
|
if inner.parent is not None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user