aboutsummaryrefslogtreecommitdiff
path: root/discord/ext
diff options
context:
space:
mode:
authorRapptz <[email protected]>2021-04-22 07:54:37 -0400
committerRapptz <[email protected]>2021-04-23 02:23:07 -0400
commit8e9860077d5238f16d98b1537b68fa5ee8071000 (patch)
treece23faddaf45e47f84433c23c48f379154ec71d1 /discord/ext
parentFix typo in FlagConverter docs (diff)
downloaddiscord.py-8e9860077d5238f16d98b1537b68fa5ee8071000.tar.xz
discord.py-8e9860077d5238f16d98b1537b68fa5ee8071000.zip
[commands] Fix flag detection code in get_flags
Diffstat (limited to 'discord/ext')
-rw-r--r--discord/ext/commands/flags.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/discord/ext/commands/flags.py b/discord/ext/commands/flags.py
index abffbbcd..14ebb774 100644
--- a/discord/ext/commands/flags.py
+++ b/discord/ext/commands/flags.py
@@ -184,7 +184,7 @@ def get_flags(namespace: Dict[str, Any], globals: Dict[str, Any], locals: Dict[s
annotation = flag.annotation = resolve_annotation(flag.annotation, globals, locals, cache)
- if flag.default is MISSING and issubclass(annotation, FlagConverter) and annotation._can_be_constructible():
+ if flag.default is MISSING and hasattr(annotation, '__commands_is_flag__') and annotation._can_be_constructible():
flag.default = annotation._construct_default
if flag.aliases is MISSING:
@@ -236,7 +236,7 @@ def get_flags(namespace: Dict[str, Any], globals: Dict[str, Any], locals: Dict[s
flag.override = False
# Validate flag names are unique
- name = flag.name.casefold() if case_insensitive else flag.name
+ name = flag.name.casefold() if case_insensitive else flag.name
if name in names:
raise TypeError(f'{flag.name!r} flag conflicts with previous flag or alias.')
else:
@@ -340,7 +340,7 @@ class FlagsMeta(type):
keys = list(re.escape(k) for k in flags)
keys.extend(re.escape(a) for a in aliases)
keys = sorted(keys, key=lambda t: len(t), reverse=True)
-
+
joined = '|'.join(keys)
pattern = re.compile(f'(({re.escape(prefix)})(?P<flag>{joined}){re.escape(delimiter)})', regex_flags)
attrs['__commands_flag_regex__'] = pattern