aboutsummaryrefslogtreecommitdiffstats
path: root/bot
diff options
context:
space:
mode:
authorGravatar ks123 <[email protected]>2020-03-23 11:52:55 +0200
committerGravatar ks123 <[email protected]>2020-03-23 11:52:55 +0200
commitece3b4ae490d2ce19d5006b49cf6272356cdba62 (patch)
tree19dbd3231344ac477f01797aeae98025ef1d517b /bot
parent(Games Cog): Created new helper function `get_best_results` to match not corr... (diff)
(Games Cog): Added wrong genre matching to `.games <genre>` command.
Diffstat (limited to 'bot')
-rw-r--r--bot/seasons/evergreen/game.py18
1 files changed, 15 insertions, 3 deletions
diff --git a/bot/seasons/evergreen/game.py b/bot/seasons/evergreen/game.py
index 79fe8ae9..688c7e35 100644
--- a/bot/seasons/evergreen/game.py
+++ b/bot/seasons/evergreen/game.py
@@ -197,9 +197,21 @@ class Games(Cog):
try:
games = await self.get_games_list(amount, self.genres[genre], offset=random.randint(0, 150))
except KeyError:
- possibilities = "`, `".join(difflib.get_close_matches(genre, self.genres))
- await ctx.send(f"Invalid genre `{genre}`. {f'Maybe you meant `{possibilities}`?' if possibilities else ''}")
- return
+ possibilities = await self.get_best_results(genre)
+ possibility = None
+ # Check is there any possibility that ratio is higher than 0.60
+ for p in possibilities:
+ if p[0] >= 0.60:
+ possibility = await self.get_games_list(amount, self.genres[p[1]], offset=random.randint(0, 150))
+ genre = p[1]
+ break
+ if possibility:
+ games = possibility
+ else:
+ await ctx.send(
+ f"Invalid genre `{genre}`. {f'Maybe you meant `{possibilities}`?' if possibilities else ''}"
+ )
+ return
# Create pages and paginate
pages = [await self.create_page(game) for game in games]