From 50782392a5d41dc4c6e89a29cb8248cc352aa912 Mon Sep 17 00:00:00 2001 From: mudkipdev Date: Sun, 7 May 2023 21:28:09 -0600 Subject: [PATCH] revert all permission changes --- example.config.toml | 4 ++-- scnewsbot/__main__.py | 9 --------- scnewsbot/utils.py | 4 ++-- 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/example.config.toml b/example.config.toml index 54b5382..1d8842d 100644 --- a/example.config.toml +++ b/example.config.toml @@ -8,14 +8,14 @@ extensions = [ "extensions.templates" ] -[permissions.announcements] +[permissions] # This works in a whitelist mode. The invoker of the command must be in an allowed guild and # must have an allowed role. If neither of those are true, allowed_users is checked last. allowed_guilds = [] allowed_roles = [] allowed_users = [] -[permissions.announcements.debug] +[permissions.debug] # This works in addition to the regular permissions, but only if debug mode is enabled. allowed_guilds = [] allowed_roles = [] diff --git a/scnewsbot/__main__.py b/scnewsbot/__main__.py index 2f21c39..afe718a 100644 --- a/scnewsbot/__main__.py +++ b/scnewsbot/__main__.py @@ -9,21 +9,12 @@ class InvalidTokenException(Exception): pass -class InvalidConfigException(Exception): - pass - - def main() -> None: DISCORD_TOKEN = os.getenv("DISCORD_TOKEN") if not DISCORD_TOKEN: raise InvalidTokenException("A Discord token was not set.") with open("config.toml", "rb") as config_file: - if "[permissions]" in config_file.read(): - raise InvalidConfigException( - "The format for permissions has changed; please check the new example config." - ) - config = Config(tomllib.load(config_file)) bot = Bot(config) diff --git a/scnewsbot/utils.py b/scnewsbot/utils.py index e4f4db9..1821824 100644 --- a/scnewsbot/utils.py +++ b/scnewsbot/utils.py @@ -34,11 +34,11 @@ class Config: return self._get_allowed_objects("allowed_users") def _get_allowed_objects(self, object_name, /) -> list: - allowed_objects = self.config["permissions"]["announcements"].get( + allowed_objects = self.config["permissions"].get( object_name, [] ) if self.debug: - allowed_objects += self.config["permissions"]["announcements"]["debug"].get( + allowed_objects += self.config["permissions"]["debug"].get( object_name, [] )