diff --git a/discord/app/commands.py b/discord/app/commands.py index 832d7d0496..27f15de099 100644 --- a/discord/app/commands.py +++ b/discord/app/commands.py @@ -36,7 +36,7 @@ from ..message import Message from .context import InteractionContext from ..utils import find, get_or_fetch - +from ..errors import NotFound class ApplicationCommand: def __repr__(self): @@ -88,7 +88,7 @@ def __init__(self, func: Callable, *args, **kwargs) -> None: for a, o in options.items(): o = o.annotation if not isinstance(o, Option): - o = Option(o, 'No description provided') + o = Option(o, "No description provided") if o.name is None: o.name = a self.options.append(o) @@ -128,7 +128,12 @@ async def invoke(self, interaction) -> None: ): arg = await get_or_fetch(ctx.guild, op.input_type.name, int(arg)) - # TODO: Add discord.Mentionable + elif op.input_type == SlashCommandOptionType.mentionable: + try: + arg = await get_or_fetch(ctx.guild, "member", int(arg)) + except NotFound: + arg = await get_or_fetch(ctx.guild, "role", int(arg)) + final_args.append(arg) await self.callback(ctx, *final_args) diff --git a/discord/app/context.py b/discord/app/context.py index d903707ae2..846b983a4e 100644 --- a/discord/app/context.py +++ b/discord/app/context.py @@ -25,6 +25,7 @@ from ..interactions import Interaction from ..utils import cached_property + class InteractionContext: def __init__(self, interaction: Interaction): self.interaction = interaction @@ -59,4 +60,4 @@ def respond(self): @property def defer(self): - return self.interaction.response.defer \ No newline at end of file + return self.interaction.response.defer