Add client context_menu decorator
@@ -524,7 +524,6 @@ class SlashCommand:
options: list = None,
default_permission: bool = True,
permissions: typing.Dict[int, list] = None,
- context: typing.Dict[str, int] = None,
connector: dict = None,
has_subcommands: bool = False,
):
@@ -549,7 +548,6 @@ class SlashCommand:
:type default_permission: bool
:param permissions: Dictionary of permissions of the slash command. Key being target guild_id and value being a list of permissions to apply. Default ``None``.
:type permissions: dict
- :param context: Dictionary of context menus of the slash command. Key being menu command name and value as the menu type. Default ``None``.
:param connector: Kwargs connector for the command. Default ``None``.
:type connector: dict
:param has_subcommands: Whether it has subcommand. Default ``False``.
@@ -583,7 +581,6 @@ class SlashCommand:
"api_options": options,
"default_permission": default_permission,
"api_permissions": permissions,
- "api_context": context,
"connector": connector or {},
"has_subcommands": has_subcommands,
}
@@ -716,7 +713,6 @@ class SlashCommand:
options: typing.List[dict] = None,
default_permission: bool = True,
permissions: dict = None,
- context: dict = None,
connector: dict = None,
):
"""
@@ -772,8 +768,6 @@ class SlashCommand:
:type default_permission: bool
:param permissions: Permission requirements of the slash command. Default ``None``.
:type permissions: dict
- :param context: Context menus of the slash command. Default ``None``.
- :type context: dict
:param connector: Kwargs connector for the command. Default ``None``.
:type connector: dict
"""
@@ -798,7 +792,6 @@ class SlashCommand:
options,
default_permission,
permissions,
- context,
connector,
)
@@ -923,6 +916,40 @@ class SlashCommand:
return wrapper
+ def context_menu(
+ self,
+ target: int,
+ name: str,
+ guild_ids: list = None
+ ):
+ """
+ Decorator that adds context menu commands.
+
+ :param target: The type of menu.
+ :type target: int
+ :param name: A name to register as the command in the menu.
+ :type name: str
+ :param guild_ids: A list of guild IDs to register the command under. Defaults to ``None``.
+ :type guild_ids: list
+ """
+
+ def wrapper(cmd):
+ decorator_name = getattr(cmd, "__name__", None)
+ decorator_type = getattr(cmd, "__target__", None)
+ decorator_guilds = guild_ids or []
+
+ obj = self.add_slash_command(
+ cmd,
+ name,
+ "",
+ guild_ids
+ )
+
+ return obj
+
+ return wrapper
+
+
def add_component_callback(
self,
callback: typing.Coroutine,
