Add kwargs to embeds, hide wordle spoilers

pull/124/head
stijndcl 2022-07-27 21:32:26 +02:00
parent 4a137bcad8
commit bdaf8a1dc5
5 changed files with 15 additions and 12 deletions

View File

@ -13,7 +13,7 @@ class EmbedBaseModel(ABC):
"""Abstract base class for a model that can be turned into a Discord embed"""
@abstractmethod
def to_embed(self) -> discord.Embed:
def to_embed(self, **kwargs: dict) -> discord.Embed:
"""Turn this model into a Discord embed"""
raise NotImplementedError

View File

@ -33,7 +33,7 @@ class GoogleSearch(EmbedBaseModel):
return embed
@overrides
def to_embed(self) -> discord.Embed:
def to_embed(self, **kwargs: dict) -> discord.Embed:
if not self.data.results or self.data.status_code != HTTPStatus.OK:
return self._error_embed()

View File

@ -47,7 +47,7 @@ class UforaNotification(EmbedBaseModel):
self.published_dt = self._published_datetime()
self._published = self._get_published()
def to_embed(self) -> discord.Embed:
def to_embed(self, **kwargs: dict) -> discord.Embed:
"""Turn the notification into an embed"""
embed = discord.Embed(colour=discord.Colour.from_rgb(30, 100, 200))

View File

@ -46,7 +46,7 @@ class Definition(EmbedPydantic):
return string_utils.abbreviate(field, max_length=Limits.EMBED_FIELD_VALUE_LENGTH)
@overrides
def to_embed(self) -> discord.Embed:
def to_embed(self, **kwargs: dict) -> discord.Embed:
embed = discord.Embed(colour=colours.urban_dictionary_green())
embed.set_author(name="Urban Dictionary")

View File

@ -94,7 +94,9 @@ class WordleEmbed(EmbedBaseModel):
return emojis
@overrides
def to_embed(self) -> discord.Embed:
def to_embed(self, **kwargs) -> discord.Embed:
only_colours = kwargs.get("only_colours", False)
colours = self.colour_code_game()
embed = discord.Embed(colour=discord.Colour.blue(), title="Wordle")
@ -102,15 +104,16 @@ class WordleEmbed(EmbedBaseModel):
rows = [" ".join(row) for row in emojis]
# Don't reveal anything if we only want to show the colours
if not only_colours:
for i, guess in enumerate(self.game.guesses):
rows[i] += f" ||{guess.upper()}||"
embed.description = "\n\n".join(rows)
# If the game is over, reveal the word
if self.game.is_game_over(self.word):
embed.description += f"\n\nThe word was **{self.word.upper()}**!"
rows.append(f"\n\nThe word was **{self.word.upper()}**!")
embed.description = "\n\n".join(rows)
embed.set_footer(text=footer())
return embed