diff options
author | 2019-09-18 20:00:02 +0200 | |
---|---|---|
committer | 2019-09-18 20:00:02 +0200 | |
commit | 1d6f7a86394587e4e735101874ef80f15537541a (patch) | |
tree | 6a418cf7fa273d06e4835b527c329f27f64acf8b | |
parent | Escape markdown in codeblock suggestion embed (diff) | |
parent | Merge pull request #436 from python-discord/enhance-offtopicnames-search (diff) |
Merge branch 'master' into codeblock-suggestion-escape-markdown
-rw-r--r-- | bot/cogs/off_topic_names.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/bot/cogs/off_topic_names.py b/bot/cogs/off_topic_names.py index cb8a03374..1f6ed80b5 100644 --- a/bot/cogs/off_topic_names.py +++ b/bot/cogs/off_topic_names.py @@ -144,20 +144,21 @@ class OffTopicNames(Cog): @otname_group.command(name='search', aliases=('s',)) @with_role(*MODERATION_ROLES) - async def search_command(self, ctx, *, query: str): + async def search_command(self, ctx, *, query: OffTopicName): """ Search for an off-topic name. """ result = await self.bot.api_client.get('bot/off-topic-channel-names') - matches = difflib.get_close_matches(query, result, n=10, cutoff=0.35) - lines = sorted(f"• {name}" for name in matches) + in_matches = {name for name in result if query in name} + close_matches = difflib.get_close_matches(query, result, n=10, cutoff=0.70) + lines = sorted(f"• {name}" for name in in_matches.union(close_matches)) embed = Embed( title=f"Query results", colour=Colour.blue() ) - if matches: + if lines: await LinePaginator.paginate(lines, ctx, embed, max_size=400, empty=False) else: embed.description = "Nothing found." |