From 1d1bba1f9072c15d64f6211f1cbf3f4aa08f8e87 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Sat, 12 Mar 2022 09:28:46 -0500 Subject: [PATCH] Support app_commands.guilds decorator for context menu commands --- discord/app_commands/commands.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/discord/app_commands/commands.py b/discord/app_commands/commands.py index dbb590f1a..3b945bad4 100644 --- a/discord/app_commands/commands.py +++ b/discord/app_commands/commands.py @@ -618,6 +618,7 @@ class ContextMenu: name: str, callback: ContextMenuCallback, type: AppCommandType, + guild_ids: Optional[List[int]] = None, ): self.name: str = validate_context_menu_name(name) self._callback: ContextMenuCallback = callback @@ -628,6 +629,7 @@ class ContextMenu: self._param_name = param self._annotation = annotation self.module: Optional[str] = callback.__module__ + self._guild_ids = guild_ids @property def callback(self) -> ContextMenuCallback: @@ -645,6 +647,7 @@ class ContextMenu: self._param_name = param self._annotation = annotation self.module = callback.__module__ + self._guild_ids = None return self 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] def decorator(inner: T) -> T: - if isinstance(inner, Group): + if isinstance(inner, (Group, ContextMenu)): inner._guild_ids = defaults elif isinstance(inner, Command): if inner.parent is not None: