From d5421cf64c78785dfac51040fbcd31182cae5cd8 Mon Sep 17 00:00:00 2001 From: Louis Chauvet Date: Sun, 5 Apr 2020 20:48:00 +0200 Subject: [PATCH] [mod-base] Auth n'est pas async --- modules/base/Base.py | 6 +++--- modules/base/BaseLua.py | 4 ++-- modules/errors/__init__.py | 4 +++- modules/perdu/__init__.py | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/modules/base/Base.py b/modules/base/Base.py index 0afa54f..9401fa0 100644 --- a/modules/base/Base.py +++ b/modules/base/Base.py @@ -45,8 +45,8 @@ class BaseClass: inline=False) await channel.send(embed=embed) - async def auth(self, user: discord.User, role_list: List[int] = None, user_list: List[int] = None, - guild: int = None): + def auth(self, user: discord.User, role_list: List[int] = None, user_list: List[int] = None, + guild: int = None): """ Return True if user is an owner of the bot or in authorized_users or he have a role in authorized_roles. @@ -93,7 +93,7 @@ class BaseClass: self.client.config["prefix"] + (self.config.command_text if self.config.command_text else "")) sub_command, args, kwargs = self._parse_command_content(content) sub_command = "com_" + sub_command - if await self.auth(message.author): + if self.auth(message.author): if sub_command in dir(self): await self.__getattribute__(sub_command)(message, args, kwargs) else: diff --git a/modules/base/BaseLua.py b/modules/base/BaseLua.py index 187d223..51c57cd 100644 --- a/modules/base/BaseLua.py +++ b/modules/base/BaseLua.py @@ -66,8 +66,8 @@ class BaseClassLua(BaseClass): self.client.config["prefix"] + (self.command_text if self.command_text else "")) sub_command, args, kwargs = self._parse_command_content(content) sub_command = "com_" + sub_command - if await self.auth(message.author): - self.call(sub_command, args, kwargs) + if self.auth(message.author): + self.call(sub_command, args, kwargs) else: await self.unauthorized(message) diff --git a/modules/errors/__init__.py b/modules/errors/__init__.py index fc3fcf4..68d9b40 100644 --- a/modules/errors/__init__.py +++ b/modules/errors/__init__.py @@ -95,7 +95,9 @@ class MainClass(BaseClassPython): await message.add_reaction("🗑️") try: - reaction, user = await self.client.wait_for('reaction_add', timeout=60.0, check=lambda r, u: r.emoji == "🗑️" and not u.bot and await self.auth(user)) + reaction, user = await self.client.wait_for('reaction_add', timeout=60.0, check=lambda r, + u: r.emoji == "🗑️" and not u.bot and self.auth( + user)) except asyncio.TimeoutError: await message.delete() else: diff --git a/modules/perdu/__init__.py b/modules/perdu/__init__.py index 6d0278a..0f45ecd 100644 --- a/modules/perdu/__init__.py +++ b/modules/perdu/__init__.py @@ -84,7 +84,7 @@ class MainClass(BaseClassPython): return saved_messages async def com_fill(self, message: discord.Message, args, kwargs): - if await self.auth(message.author): + if self.auth(message.author): async with message.channel.typing(): await self.fill_history() await message.channel.send("Fait.")