Add on_red_before_identify dispatch (#4647)

* add before_identify_hook with `on_identify` dispatch

* move before_identify_hook closer to other "hooks"

* add `red_` prefix to avoid potential conflict

* on_red_before_identify

Co-authored-by: Fixator10 <fixator10@users.noreply.github.com>
This commit is contained in:
Fixator10 2021-01-21 13:20:20 +04:00 committed by GitHub
parent 41e980c517
commit 315b3e5c98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -384,6 +384,12 @@ class RedBase(
self._red_before_invoke_objs.add(coro) self._red_before_invoke_objs.add(coro)
return coro return coro
async def before_identify_hook(self, shard_id, *, initial=False):
"""A hook that is called before IDENTIFYing a session.
Same as in discord.py, but also dispatches "on_red_identify" bot event."""
self.dispatch("red_before_identify", shard_id, initial)
return await super().before_identify_hook(shard_id, initial=initial)
@property @property
def cog_mgr(self) -> NoReturn: def cog_mgr(self) -> NoReturn:
raise AttributeError("Please don't mess with the cog manager internals.") raise AttributeError("Please don't mess with the cog manager internals.")