(interactions): Basic support for modals.

This commit is contained in:
2022-04-19 11:34:34 +03:00
parent e73302d21f
commit 035a295962
6 changed files with 207 additions and 11 deletions

View File

@@ -1,15 +1,23 @@
import asyncio
import uuid
import json
from .enums import ButtonStyle, InteractionType
class MessageComponent:
_type = None
interaction_type = InteractionType.MESSAGE_COMPONENT
def __init_(self, *args, **kwargs):
self.message = None
def to_dict(self):
raise NotImplementedError
def to_json(self):
return json.dumps(self.to_dict())
class ActionRow(MessageComponent):
_type = 1
@@ -26,13 +34,15 @@ class ActionRow(MessageComponent):
class AwaitableComponent:
interaction_type: InteractionType = None
async def wait_for(self, timeout=None, check=None):
from meta import client
def _check(interaction):
valid = True
print(interaction.custom_id)
valid = valid and interaction.interaction_type == InteractionType.MESSAGE_COMPONENT
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))
return valid