aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Kieran Siek <[email protected]>2019-09-18 21:31:46 +0800
committerGravatar GitHub <[email protected]>2019-09-18 21:31:46 +0800
commit83127be0bef58ee001959d421f7aefc3aee504dd (patch)
treeeada05ddd7d711ee24ee456acbf4ad9731955834
parentAdd basic tests for `bot.api`. (#424) (diff)
parentEnhance off-topic names search feature (diff)
Merge pull request #436 from python-discord/enhance-offtopicnames-search
Enhance off-topic names search feature
-rw-r--r--bot/cogs/off_topic_names.py9
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."