Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion bot/cogs/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from discord import Colour, Embed, Member, Message, NotFound, Reaction, User
from discord.ext.commands import Bot, Cog, Command, Context, Group, HelpCommand
from fuzzywuzzy import fuzz, process
from fuzzywuzzy.utils import full_process

from bot import constants
from bot.constants import Channels, Emojis, STAFF_ROLES
Expand Down Expand Up @@ -145,7 +146,13 @@ async def command_not_found(self, string: str) -> "HelpQueryNotFound":
Will return an instance of the `HelpQueryNotFound` exception with the error message and possible matches.
"""
choices = await self.get_all_help_choices()
result = process.extractBests(string, choices, scorer=fuzz.ratio, score_cutoff=60)

# Run fuzzywuzzy's processor beforehand, and avoid matching if processed string is empty
# This avoids fuzzywuzzy from raising a warning on inputs with only non-alphanumeric characters
if (processed := full_process(string)):
result = process.extractBests(processed, choices, scorer=fuzz.ratio, score_cutoff=60, processor=None)
else:
result = []

return HelpQueryNotFound(f'Query "{string}" not found.', dict(result))

Expand Down