aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Numerlor <[email protected]>2021-07-01 00:08:39 +0200
committerGravatar Numerlor <[email protected]>2021-07-06 02:02:13 +0200
commit14d6fca825bf87c35f82215da3e9561bd1db1ab8 (patch)
treea8d4ed4ddabfbbf4a07ae1229937bf59e48961f4
parentUpdate outdated docstring (diff)
Do not add suggestion for tags with short names if a group is specified
-rw-r--r--bot/exts/info/tags.py20
1 files changed, 14 insertions, 6 deletions
diff --git a/bot/exts/info/tags.py b/bot/exts/info/tags.py
index 1847fa240..798be6543 100644
--- a/bot/exts/info/tags.py
+++ b/bot/exts/info/tags.py
@@ -153,12 +153,20 @@ class Tags(Cog):
def get_fuzzy_matches(self, tag_identifier: TagIdentifier) -> list[tuple[TagIdentifier, Tag]]:
"""Get tags with identifiers similar to `tag_identifier`."""
if tag_identifier.group is None:
- suggestions = self._get_suggestions(tag_identifier)
+ if len(tag_identifier.name) < 3:
+ return []
+ else:
+ return self._get_suggestions(tag_identifier)
else:
- # Try fuzzy matching with only a name first
- suggestions = self._get_suggestions(TagIdentifier(None, tag_identifier.group))
- suggestions += self._get_suggestions(tag_identifier)
- return suggestions
+ if len(tag_identifier.group) < 3:
+ suggestions = []
+ else:
+ # Try fuzzy matching with only a name first
+ suggestions = self._get_suggestions(TagIdentifier(None, tag_identifier.group))
+
+ if not len(tag_identifier.name) < 3:
+ suggestions += self._get_suggestions(tag_identifier)
+ return suggestions
def _get_tags_via_content(
self,
@@ -269,7 +277,7 @@ class Tags(Cog):
)
return tag.embed
- elif len(tag_identifier.name) >= 3:
+ else:
suggested_tags = self.get_fuzzy_matches(tag_identifier)[:10]
if not suggested_tags:
return None