Properly resolve events

This commit is contained in:
Lonami Exo
2018-08-21 12:14:32 +02:00
parent 47190d7d55
commit d3a6822fc9
4 changed files with 36 additions and 14 deletions

View File

@@ -260,6 +260,9 @@ class Conversation(ChatGetter):
if isinstance(event, type):
event = event()
# Since we await resolve here we don't need to await resolved.
# We know it has already been resolved, unlike when normally
# adding an event handler, for which a task is created to resolve.
await event.resolve()
counter = Conversation._custom_counter
@@ -276,9 +279,6 @@ class Conversation(ChatGetter):
return await result()
async def _check_custom(self, built):
# TODO This code is quite much a copy paste of registering events
# in the client, resolving them and setting the client; perhaps
# there is a better way?
for i, (ev, fut) in self._custom.items():
ev_type = type(ev)
if built[ev_type] and ev.filter(built[ev_type]):