Don't send messages for invalid Wordle proposals; add reactions instead, and possibly multiple reactions to the same proposal if it is invalid for multiple reasons

This commit is contained in:
2022-04-05 13:45:02 +02:00
parent f226b293de
commit 9e11e45523

View File

@@ -75,14 +75,18 @@ class Game:
if len(guess) <= len(self.target) * ratio or len(self.target) <= len(guess) * ratio:
return
# check for errors and react accordingly
error = False
if WORDLE_FORCE_ALTERNATION and message.author == self.last_player:
await self.channel.send(f"{message.author.mention} Laisse un peu jouer les autres !")
return
await message.add_reaction("\N{BUSTS IN SILHOUETTE}")
error = True
if len(guess) != len(self.target):
await self.channel.send(f"{message.author.mention} Le mot à deviner fait {len(self.target)} lettres (ça ne compte pas comme un tour).")
return
await message.add_reaction("\N{LEFT RIGHT ARROW}")
error = True
if guess not in valid_words:
await self.channel.send(f"{message.author.mention} `{guess}` n'est pas dans mon dictionnaire (ça ne compte pas comme un tour).")
await message.add_reaction("\N{EXCLAMATION QUESTION MARK}")
error = True
if error:
return
# everything is OK, validate the proposal