mirror of
				https://github.com/Rapptz/discord.py.git
				synced 2025-10-24 18:13:00 +00:00 
			
		
		
		
	Add the Command.callback and ContextMenu.callback properties
This commit is contained in:
		| @@ -304,8 +304,6 @@ class Command(Generic[GroupT, P, T]): | |||||||
|     ------------ |     ------------ | ||||||
|     name: :class:`str` |     name: :class:`str` | ||||||
|         The name of the application command. |         The name of the application command. | ||||||
|     callback: :ref:`coroutine <coroutine>` |  | ||||||
|         The coroutine that is executed when the command is called. |  | ||||||
|     description: :class:`str` |     description: :class:`str` | ||||||
|         The description of the application command. This shows up in the UI to describe |         The description of the application command. This shows up in the UI to describe | ||||||
|         the application command. |         the application command. | ||||||
| @@ -329,6 +327,11 @@ class Command(Generic[GroupT, P, T]): | |||||||
|         self.on_error: Optional[Error[GroupT]] = None |         self.on_error: Optional[Error[GroupT]] = None | ||||||
|         self._params: Dict[str, CommandParameter] = _extract_parameters_from_callback(callback, callback.__globals__) |         self._params: Dict[str, CommandParameter] = _extract_parameters_from_callback(callback, callback.__globals__) | ||||||
|  |  | ||||||
|  |     @property | ||||||
|  |     def callback(self) -> CommandCallback[GroupT, P, T]: | ||||||
|  |         """:ref:`coroutine <coroutine>`: The coroutine that is executed when the command is called.""" | ||||||
|  |         return self._callback | ||||||
|  |  | ||||||
|     def _copy_with_binding(self, binding: GroupT) -> Command: |     def _copy_with_binding(self, binding: GroupT) -> Command: | ||||||
|         cls = self.__class__ |         cls = self.__class__ | ||||||
|         copy = cls.__new__(cls) |         copy = cls.__new__(cls) | ||||||
| @@ -542,8 +545,6 @@ class ContextMenu: | |||||||
|     ------------ |     ------------ | ||||||
|     name: :class:`str` |     name: :class:`str` | ||||||
|         The name of the context menu. |         The name of the context menu. | ||||||
|     callback: :ref:`coroutine <coroutine>` |  | ||||||
|         The coroutine that is executed when the context menu is called. |  | ||||||
|     type: :class:`.AppCommandType` |     type: :class:`.AppCommandType` | ||||||
|         The type of context menu application command. |         The type of context menu application command. | ||||||
|     """ |     """ | ||||||
| @@ -564,6 +565,11 @@ class ContextMenu: | |||||||
|         self._param_name = param |         self._param_name = param | ||||||
|         self._annotation = annotation |         self._annotation = annotation | ||||||
|  |  | ||||||
|  |     @property | ||||||
|  |     def callback(self) -> ContextMenuCallback: | ||||||
|  |         """:ref:`coroutine <coroutine>`: The coroutine that is executed when the context menu is called.""" | ||||||
|  |         return self._callback | ||||||
|  |  | ||||||
|     @classmethod |     @classmethod | ||||||
|     def _from_decorator(cls, callback: ContextMenuCallback, *, name: str = MISSING) -> ContextMenu: |     def _from_decorator(cls, callback: ContextMenuCallback, *, name: str = MISSING) -> ContextMenu: | ||||||
|         (param, annotation, type) = _get_context_menu_parameter(callback) |         (param, annotation, type) = _get_context_menu_parameter(callback) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user