From 76243975883347141860f2bc8d63e05eb8b74cb8 Mon Sep 17 00:00:00 2001 From: Kamal Curi Date: Fri, 19 Aug 2022 23:13:12 -0300 Subject: [PATCH] ADD: Command permisions are now more granular --- settings/config.py | 5 +++++ utils/commands.py | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/settings/config.py b/settings/config.py index 82fcfac..cccfb29 100644 --- a/settings/config.py +++ b/settings/config.py @@ -69,4 +69,9 @@ LOGGING_CONFIG = { }, } +PERMISSIONS = { + 'dq' : ['O emissário', 'BotMan'], + 'v' : ['Operador'] +} + logger.dictConfig(LOGGING_CONFIG) diff --git a/utils/commands.py b/utils/commands.py index 7cd69cd..4cfa89e 100644 --- a/utils/commands.py +++ b/utils/commands.py @@ -8,6 +8,8 @@ from discord.ext import commands from utils.database import get_by_id, get_quotes, remove_quote, set_quote, count_quotes +from settings.config import PERMISSIONS + client = commands.Bot(command_prefix='--') logger = logging.getLogger(__name__) @@ -105,7 +107,7 @@ async def delete_quote(bot, _id: int=None) -> str: syntax = "`--dq `" roles = [r.name for r in bot.author.roles] - if not 'Operador' in roles: + if len(set(PERMISSIONS['dq']).intersection(roles)) < 1: return await bot.send("_And who the fuck do **YOU** think you are!?_.\n"\ "(You don't have the necessary role for this command)") @@ -157,7 +159,7 @@ async def info(bot: object) -> str: """ roles = [r.name for r in bot.author.roles] - if not 'Operador' in roles: + if len(set(PERMISSIONS['v']).intersection(roles)) < 1: return await bot.send("_And who the fuck do **YOU** think you are!?_.\n"\ "(You don't have the necessary role for this command)")