diff options
author | 2023-02-28 15:29:51 +0200 | |
---|---|---|
committer | 2023-02-28 15:29:51 +0200 | |
commit | 93cc2596931a652ae46fb80cbeff5b991434d779 (patch) | |
tree | 9f476b882a9eec9b978e2730efcd73e3ff06a03c | |
parent | Re-add webhook and discord token check in other cogs (diff) |
Don't allow adding filter lists with no implementation
Filter lists with no implemenation are not loaded, therefore if one is added with no implementation there is then no way to interact with it.
Instead of accounting for that case it makes more sense to require an implemenation first.
-rw-r--r-- | bot/exts/filtering/filtering.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/bot/exts/filtering/filtering.py b/bot/exts/filtering/filtering.py index 66f4715f3..26e0f32d2 100644 --- a/bot/exts/filtering/filtering.py +++ b/bot/exts/filtering/filtering.py @@ -742,6 +742,15 @@ class Filtering(Cog): @has_any_role(Roles.admins) async def fl_add(self, ctx: Context, list_type: list_type_converter, list_name: str) -> None: """Add a new filter list.""" + # Check if there's an implementation. + if list_name.lower() not in filter_list_types: + if list_name.lower()[:-1] not in filter_list_types: # Maybe the name was given with uppercase or in plural? + await ctx.reply(f":x: Cannot add a `{list_name}` filter list, as there is no matching implementation.") + return + else: + list_name = list_name.lower()[:-1] + + # Check it doesn't already exist. list_description = f"{past_tense(list_type.name.lower())} {list_name.lower()}" if list_name in self.filter_lists: filter_list = self.filter_lists[list_name] |