From b9b21ca270e139dd344d7961b1ab9330609bca05 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Sun, 11 Jan 2026 08:02:50 -0500 Subject: [PATCH] [commands] Fix Context.from_interaction derived Message.type The previous Message.type when accessed from Context would be an unknown enum type because the enum was double nested when the proper type expected by the synthetic payload was an int not an enum. Fix #10382 --- discord/ext/commands/context.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/discord/ext/commands/context.py b/discord/ext/commands/context.py index 968fec419..54b3dd973 100644 --- a/discord/ext/commands/context.py +++ b/discord/ext/commands/context.py @@ -259,6 +259,7 @@ class Context(discord.abc.Messageable, Generic[BotT]): bot: BotT = interaction.client data: ApplicationCommandInteractionData = interaction.data # type: ignore + type_ = data.get('type', 1) if interaction.message is None: synthetic_payload = { 'id': interaction.id, @@ -268,7 +269,7 @@ class Context(discord.abc.Messageable, Generic[BotT]): 'tts': False, 'pinned': False, 'edited_timestamp': None, - 'type': MessageType.chat_input_command if data.get('type', 1) == 1 else MessageType.context_menu_command, + 'type': MessageType.chat_input_command.value if type_ == 1 else MessageType.context_menu_command.value, 'flags': 64, 'content': '', 'mentions': [], @@ -288,7 +289,7 @@ class Context(discord.abc.Messageable, Generic[BotT]): else: message = interaction.message - prefix = '/' if data.get('type', 1) == 1 else '\u200b' # Mock the prefix + prefix = '/' if type_ == 1 else '\u200b' # Mock the prefix ctx = cls( message=message, bot=bot,