Repository: Pycord-Development/pycord

Issue:
Add ApplicatonContext.invoke
### Summary

invoke command in other interactions

### What is the feature request for?

discord.ext.commands

### The Problem

Im trying to invoke a slash command into another slash command.I'm

### The Ideal Solution

Add the function, please.

### The Current Solution

Context.invoke, but it only works on normal context 

### Additional Context

_No response_


Discussion:

Resolving patch:
diff --git a/discord/commands/commands.py b/discord/commands/commands.py
--- a/discord/commands/commands.py
+++ b/discord/commands/commands.py
@@ -31,7 +31,8 @@
 import re
 import types
 from collections import OrderedDict
-from typing import Any, Callable, Dict, List, Optional, Type, Union, TYPE_CHECKING
+from typing import Any, Callable, Dict, Generic, List, Optional, Type, TypeVar, Union, TYPE_CHECKING
+from typing_extensions import ParamSpec
 
 from .context import ApplicationContext, AutocompleteContext
 from .errors import ApplicationCommandError, CheckFailure, ApplicationCommandInvokeError
@@ -61,9 +62,18 @@
     "MessageCommand",
 )
 
-if TYPE_CHECKING:
+if TYPE_CHECKING: 
+    from ..cog import Cog
     from ..interactions import Interaction
 
+T = TypeVar('T')
+CogT = TypeVar('CogT', bound='Cog')
+
+if TYPE_CHECKING:
+    P = ParamSpec('P')
+else:
+    P = TypeVar('P')
+
 def wrap_callback(coro):
     @functools.wraps(coro)
     async def wrapped(*args, **kwargs):
@@ -97,7 +107,7 @@ async def wrapped(arg):
 class _BaseCommand:
     __slots__ = ()
 
-class ApplicationCommand(_BaseCommand):
+class ApplicationCommand(_BaseCommand, Generic[CogT, P, T]):
     cog = None
 
     def __repr__(self):
diff --git a/discord/commands/context.py b/discord/commands/context.py
--- a/discord/commands/context.py
+++ b/discord/commands/context.py
@@ -24,11 +24,13 @@
 """
 from __future__ import annotations
 
-from typing import TYPE_CHECKING, Optional, Union
+from typing import Callable, TYPE_CHECKING, Optional, TypeVar, Union
 
 import discord.abc
 
 if TYPE_CHECKING:
+    from typing_extensions import ParamSpec
+
     import discord
     from discord import Bot
     from discord.state import ConnectionState
@@ -42,6 +44,15 @@
 from ..message import Message
 from ..user import User
 from ..utils import cached_property
+from ..webhook import Webhook
+
+T = TypeVar('T')
+CogT = TypeVar('CogT', bound="Cog")
+
+if TYPE_CHECKING:
+    P = ParamSpec('P')
+else:
+    P = TypeVar('P')
 
 __all__ = (
     "ApplicationContext",
@@ -81,6 +92,32 @@ def __init__(self, bot: Bot, interaction: Interaction):
     async def _get_channel(self) -> discord.abc.Messageable:
         return self.channel
 
+    async def invoke(self, command: ApplicationCommand[CogT, P, T], /, *args: P.args, **kwargs: P.kwargs) -> T:
+        r"""|coro|
+        Calls a command with the arguments given.
+        This is useful if you want to just call the callback that a
+        :class:`.ApplicationCommand` holds internally.
+        .. note::
+            This does not handle converters, checks, cooldowns, pre-invoke,
+            or after-invoke hooks in any matter. It calls the internal callback
+            directly as-if it was a regular function.
+            You must take care in passing the proper arguments when
+            using this function.
+        Parameters
+        -----------
+        command: :class:`.ApplicationCommand`
+            The command that is going to be called.
+        \*args
+            The arguments to use.
+        \*\*kwargs
+            The keyword arguments to use.
+        Raises
+        -------
+        TypeError
+            The command argument to invoke is missing.
+        """
+        return await command(self, *args, **kwargs)
+
     @cached_property
     def channel(self):
         return self.interaction.channel


Test patch: