Allow event's func to be async (#1461)

Fixes #1344.
This commit is contained in:
JuniorJPDJ
2020-05-16 09:58:37 +02:00
committed by GitHub
parent c45f2e7c39
commit 634bc3a8bd
5 changed files with 33 additions and 15 deletions

View File

@@ -46,6 +46,8 @@ class Raw(EventBuilder):
return update
def filter(self, event):
if ((not self.types or isinstance(event, self.types))
and (not self.func or self.func(event))):
if not self.types or isinstance(event, self.types):
if self.func:
# Return the result of func directly as it may need to be awaited
return self.func(event)
return event