diff --git a/disnake/ext/commands/common_bot_base.py b/disnake/ext/commands/common_bot_base.py index 05728bedc4..0e7076190a 100644 --- a/disnake/ext/commands/common_bot_base.py +++ b/disnake/ext/commands/common_bot_base.py @@ -80,9 +80,7 @@ async def _fill_owners(self) -> None: if self.owner_id or self.owner_ids: return - await self.wait_until_first_connect() # type: ignore - - app = await self.application_info() # type: ignore + app: disnake.AppInfo = await self.application_info() # type: ignore if app.team: self.owners = set(app.team.members) self.owner_ids = {m.id for m in app.team.members} @@ -111,11 +109,13 @@ async def close(self) -> None: @disnake.utils.copy_doc(disnake.Client.login) async def login(self, token: str) -> None: - self.loop.create_task(self._fill_owners()) # type: ignore + await super().login(token=token) # type: ignore if self.reload: self.loop.create_task(self._watchdog()) # type: ignore - await super().login(token=token) # type: ignore + + # prefetch + self.loop.create_task(self._fill_owners()) # type: ignore async def is_owner(self, user: Union[disnake.User, disnake.Member]) -> bool: """|coro| @@ -140,20 +140,13 @@ async def is_owner(self, user: Union[disnake.User, disnake.Member]) -> bool: :class:`bool` Whether the user is the owner. """ + if not self.owner_id and not self.owner_ids: + await self._fill_owners() + if self.owner_id: return user.id == self.owner_id - elif self.owner_ids: - return user.id in self.owner_ids else: - app = await self.application_info() # type: ignore - if app.team: - self.owners = set(app.team.members) - self.owner_ids = ids = {m.id for m in app.team.members} - return user.id in ids - else: - self.owner = app.owner - self.owner_id = owner_id = app.owner.id - return user.id == owner_id + return user.id in self.owner_ids def add_cog(self, cog: Cog, *, override: bool = False) -> None: """Adds a "cog" to the bot.