[mod-base] Auth n'est pas async

This commit is contained in:
Louis Chauvet 2020-04-05 20:48:00 +02:00
parent aa633bf5e1
commit d5421cf64c
Signed by: fomys
GPG Key ID: 1ECA046A9615ABA0
4 changed files with 9 additions and 7 deletions

View File

@ -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:

View File

@ -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)

View File

@ -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:

View File

@ -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.")