Petits oublis

This commit is contained in:
Fomys 2019-08-08 22:55:07 +02:00
parent b22744b802
commit 8be784d6c4
Signed by: fomys
GPG Key ID: 1ECA046A9615ABA0
2 changed files with 6 additions and 12 deletions

View File

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

View File

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