mirror of
https://github.com/Rapptz/discord.py.git
synced 2026-01-15 18:51:41 +00:00
[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
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user