diff options
author | 2020-08-03 11:50:11 -0400 | |
---|---|---|
committer | 2020-08-03 11:50:11 -0400 | |
commit | 3649c2a03dc158a25f2c3be98db8691f903a1953 (patch) | |
tree | 338e33e61236788305f24a63246d04878b43449d | |
parent | Add some feedback to the _sync_data helper. (diff) | |
parent | Add support for plural FilterList types. (diff) |
Merge pull request #1078 from python-discord/support_plural_filterlist_types
Add support for plural FilterList types.
-rw-r--r-- | bot/converters.py | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/bot/converters.py b/bot/converters.py index c9f525dd1..1358cbf1e 100644 --- a/bot/converters.py +++ b/bot/converters.py @@ -101,11 +101,23 @@ class ValidFilterListType(Converter): list_type = list_type.upper() if list_type not in valid_types: - valid_types_list = '\n'.join([f"• {type_.lower()}" for type_ in valid_types]) - raise BadArgument( - f"You have provided an invalid list type!\n\n" - f"Please provide one of the following: \n{valid_types_list}" - ) + + # Maybe the user is using the plural form of this type, + # e.g. "guild_invites" instead of "guild_invite". + # + # This code will support the simple plural form (a single 's' at the end), + # which works for all current list types, but if a list type is added in the future + # which has an irregular plural form (like 'ies'), this code will need to be + # refactored to support this. + if list_type.endswith("S") and list_type[:-1] in valid_types: + list_type = list_type[:-1] + + else: + valid_types_list = '\n'.join([f"• {type_.lower()}" for type_ in valid_types]) + raise BadArgument( + f"You have provided an invalid list type!\n\n" + f"Please provide one of the following: \n{valid_types_list}" + ) return list_type |