Automatically add `text` and `raw_text` attributes to an `Event` object to avoid weird logspam from dochub modules

pull/1/head
hikari.ftg 2022-04-07 13:31:24 +00:00
parent 3cf750a586
commit b71f51e8ea
1 changed files with 6 additions and 0 deletions

View File

@ -424,6 +424,12 @@ class CommandDispatcher:
logging.debug(f"Ignored watcher of module {modname}")
continue
# Avoid weird AttributeErrors in weird dochub modules by settings placeholder
# of attributes
for placeholder in {"text", "raw_text"}:
if not hasattr(event, placeholder):
setattr(event, placeholder, "")
# Run watcher via ensure_future so in case user has a lot
# of watchers with long actions, they can run simultaneously
asyncio.ensure_future(