From 0120e158e867374bfb5d7f9d1531de2166ba5462 Mon Sep 17 00:00:00 2001 From: Zalk0 <88582103+zalk0@users.noreply.github.com> Date: Thu, 22 Feb 2024 14:59:04 +0100 Subject: [PATCH] fix: simplify is_team_member_or_owner --- bot.py | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/bot.py b/bot.py index faecf51..0b05992 100644 --- a/bot.py +++ b/bot.py @@ -54,10 +54,6 @@ def __init__(self): # Declare command tree self.tree = discord.app_commands.CommandTree(self) - # Variable for storing owners id - # If set manually, it will not fetch from the bot's application info - self.owners = [] - # Used to check the first time the bot does the on_ready event self.first = True @@ -115,13 +111,10 @@ async def on_message(self, message: discord.Message): self.bot_logger.info(f'{self.user} responded to {author}: "{response[0]}"') async def is_team_member_or_owner(self, author: discord.User) -> bool: - if not self.owners: - app_info = await self.application_info() - if app_info.team: - self.owners = [member.id for member in app_info.team.members] - else: - self.owners = [app_info.owner.id] - return author.id in self.owners + if self.application.team: + return author.id in self.application.team.members + else: + return author.id == self.application.owner.id # Add a basic HTTP server to check if the bot is up async def start_server(self):