[mod-base] Auth n'est pas async
This commit is contained in:
parent
aa633bf5e1
commit
d5421cf64c
@ -45,8 +45,8 @@ class BaseClass:
|
|||||||
inline=False)
|
inline=False)
|
||||||
await channel.send(embed=embed)
|
await channel.send(embed=embed)
|
||||||
|
|
||||||
async def auth(self, user: discord.User, role_list: List[int] = None, user_list: List[int] = None,
|
def auth(self, user: discord.User, role_list: List[int] = None, user_list: List[int] = None,
|
||||||
guild: 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.
|
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 ""))
|
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, args, kwargs = self._parse_command_content(content)
|
||||||
sub_command = "com_" + sub_command
|
sub_command = "com_" + sub_command
|
||||||
if await self.auth(message.author):
|
if self.auth(message.author):
|
||||||
if sub_command in dir(self):
|
if sub_command in dir(self):
|
||||||
await self.__getattribute__(sub_command)(message, args, kwargs)
|
await self.__getattribute__(sub_command)(message, args, kwargs)
|
||||||
else:
|
else:
|
||||||
|
@ -66,8 +66,8 @@ class BaseClassLua(BaseClass):
|
|||||||
self.client.config["prefix"] + (self.command_text if self.command_text else ""))
|
self.client.config["prefix"] + (self.command_text if self.command_text else ""))
|
||||||
sub_command, args, kwargs = self._parse_command_content(content)
|
sub_command, args, kwargs = self._parse_command_content(content)
|
||||||
sub_command = "com_" + sub_command
|
sub_command = "com_" + sub_command
|
||||||
if await self.auth(message.author):
|
if self.auth(message.author):
|
||||||
self.call(sub_command, args, kwargs)
|
self.call(sub_command, args, kwargs)
|
||||||
else:
|
else:
|
||||||
await self.unauthorized(message)
|
await self.unauthorized(message)
|
||||||
|
|
||||||
|
@ -95,7 +95,9 @@ class MainClass(BaseClassPython):
|
|||||||
await message.add_reaction("🗑️")
|
await message.add_reaction("🗑️")
|
||||||
|
|
||||||
try:
|
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:
|
except asyncio.TimeoutError:
|
||||||
await message.delete()
|
await message.delete()
|
||||||
else:
|
else:
|
||||||
|
@ -84,7 +84,7 @@ class MainClass(BaseClassPython):
|
|||||||
return saved_messages
|
return saved_messages
|
||||||
|
|
||||||
async def com_fill(self, message: discord.Message, args, kwargs):
|
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():
|
async with message.channel.typing():
|
||||||
await self.fill_history()
|
await self.fill_history()
|
||||||
await message.channel.send("Fait.")
|
await message.channel.send("Fait.")
|
||||||
|
Loading…
Reference in New Issue
Block a user