From 413b54c5ab22b0d6ea0d8ef2a219fe371022d88f Mon Sep 17 00:00:00 2001 From: Conatum Date: Tue, 19 Apr 2022 13:46:44 +0300 Subject: [PATCH] (interactions): Support message response. --- bot/meta/interactions/components.py | 1 - bot/meta/interactions/interactions.py | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/bot/meta/interactions/components.py b/bot/meta/interactions/components.py index c7788546..81f21145 100644 --- a/bot/meta/interactions/components.py +++ b/bot/meta/interactions/components.py @@ -41,7 +41,6 @@ class AwaitableComponent: def _check(interaction): valid = True - print(interaction.custom_id) valid = valid and interaction.interaction_type == self.interaction_type valid = valid and interaction.custom_id == self.custom_id valid = valid and (check is None or check(interaction)) diff --git a/bot/meta/interactions/interactions.py b/bot/meta/interactions/interactions.py index f51df5ed..c1ec18e9 100644 --- a/bot/meta/interactions/interactions.py +++ b/bot/meta/interactions/interactions.py @@ -9,6 +9,27 @@ class Interaction: '_state' ) + async def response(self, content=None, embeds=None, components=None, ephemeral=None): + data = {} + if content is not None: + data['content'] = str(content) + + if embeds is not None: + data['embeds'] = [embed.to_dict() for embed in embeds] + + if components is not None: + data['components'] = [component.to_dict() for component in components] + + if ephemeral is not None: + data['flags'] = 1 << 6 + + return await self._state.http.interaction_callback( + self.id, + self.token, + InteractionCallback.CHANNEL_MESSAGE_WITH_SOURCE, + data + ) + async def response_deferred(self): return await self._state.http.interaction_callback( self.id,