From 8be784d6c4f26bc0f1266b2dd65ce7485d56dcd2 Mon Sep 17 00:00:00 2001 From: Fomys Date: Thu, 8 Aug 2019 22:55:07 +0200 Subject: [PATCH] Petits oublis --- modules/base/Base.py | 3 +++ modules/base/BaseLua.py | 15 +++------------ 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/modules/base/Base.py b/modules/base/Base.py index 4db4d80..96641fa 100644 --- a/modules/base/Base.py +++ b/modules/base/Base.py @@ -54,6 +54,9 @@ class BaseClass: async def auth(self, user, role_list=None): if role_list is None: role_list = self.authorized_roles + if len(role_list) == 0: + # Everyone can use this command + return True if type(role_list) == list: if user.id in self.client.owners: return True diff --git a/modules/base/BaseLua.py b/modules/base/BaseLua.py index 3397065..b0f5cad 100644 --- a/modules/base/BaseLua.py +++ b/modules/base/BaseLua.py @@ -56,12 +56,7 @@ class BaseClassLua(BaseClass): def dispatch(self, event, *args, **kwargs): method = "on_"+event - if self.luaMethods[method] is not None: - async def coro(*args, **kwargs): - self.luaMethods[method](self, asyncio.ensure_future, discord, *args, **kwargs) - asyncio.ensure_future(self.client._run_event(coro, method, *args, **kwargs), loop=self.client.loop) - else: # If lua method not found, pass - super().dispatch(event, *args, **kwargs) + self.call(method, *args, **kwargs) async def parse_command(self, message): """Parse a command_text from received message and execute function @@ -78,11 +73,7 @@ class BaseClassLua(BaseClass): sub_command, args, kwargs = self._parse_command_content(content) sub_command = "com_" + sub_command if await self.auth(message.user): - if self.luaMethods[sub_command] is not None: - self.luaMethods[sub_command](self, asyncio.ensure_future, discord, message, args, kwargs) - else: - if self.luaMethods["command"] is not None: - self.luaMethods["command"](self, asyncio.ensure_future, discord, message, [sub_command[4:]] + args, kwargs) + self.call(sub_command, args, kwargs) else: - await self.unautorized(message, [sub_command[4:]] + args, kwargs) + await self.unauthorized(message)