From a5d23b515345ff12491c7cd29f1658d928ac8e36 Mon Sep 17 00:00:00 2001 From: Conatum Date: Mon, 25 Apr 2022 22:35:49 +0300 Subject: [PATCH] fix (interactions): Allow empty `message`. In some circumstances, interactions may be returned with no `message`. Fixes a bug causing this to crash the entire event loop. --- bot/meta/patches.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/bot/meta/patches.py b/bot/meta/patches.py index f692c4da..8f25c39c 100644 --- a/bot/meta/patches.py +++ b/bot/meta/patches.py @@ -229,13 +229,16 @@ def parse_interaction_create(self, data): # Assume user user = self.get_user(_get_as_snowflake(data['user'], 'id')) or User(data=data['user'], state=self) - message = self._get_message(_get_as_snowflake(data['message'], 'id')) - if not message: - message_data = data['message'] - channel, _ = self._get_guild_channel(message_data) - message = Message(data=message_data, channel=channel, state=self) - if self._messages is not None: - self._messages.append(message) + if 'message' in data: + message = self._get_message(_get_as_snowflake(data['message'], 'id')) + if not message: + message_data = data['message'] + channel, _ = self._get_guild_channel(message_data) + message = Message(data=message_data, channel=channel, state=self) + if self._messages is not None: + self._messages.append(message) + else: + message = None interaction = None if data['type'] == InteractionType.MESSAGE_COMPONENT: