mirror of https://github.com/stijndcl/didier
Add kwargs to embeds, hide wordle spoilers
parent
4a137bcad8
commit
bdaf8a1dc5
|
@ -13,7 +13,7 @@ class EmbedBaseModel(ABC):
|
||||||
"""Abstract base class for a model that can be turned into a Discord embed"""
|
"""Abstract base class for a model that can be turned into a Discord embed"""
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def to_embed(self) -> discord.Embed:
|
def to_embed(self, **kwargs: dict) -> discord.Embed:
|
||||||
"""Turn this model into a Discord embed"""
|
"""Turn this model into a Discord embed"""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ class GoogleSearch(EmbedBaseModel):
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
@overrides
|
@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:
|
if not self.data.results or self.data.status_code != HTTPStatus.OK:
|
||||||
return self._error_embed()
|
return self._error_embed()
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ class UforaNotification(EmbedBaseModel):
|
||||||
self.published_dt = self._published_datetime()
|
self.published_dt = self._published_datetime()
|
||||||
self._published = self._get_published()
|
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"""
|
"""Turn the notification into an embed"""
|
||||||
embed = discord.Embed(colour=discord.Colour.from_rgb(30, 100, 200))
|
embed = discord.Embed(colour=discord.Colour.from_rgb(30, 100, 200))
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ class Definition(EmbedPydantic):
|
||||||
return string_utils.abbreviate(field, max_length=Limits.EMBED_FIELD_VALUE_LENGTH)
|
return string_utils.abbreviate(field, max_length=Limits.EMBED_FIELD_VALUE_LENGTH)
|
||||||
|
|
||||||
@overrides
|
@overrides
|
||||||
def to_embed(self) -> discord.Embed:
|
def to_embed(self, **kwargs: dict) -> discord.Embed:
|
||||||
embed = discord.Embed(colour=colours.urban_dictionary_green())
|
embed = discord.Embed(colour=colours.urban_dictionary_green())
|
||||||
embed.set_author(name="Urban Dictionary")
|
embed.set_author(name="Urban Dictionary")
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,9 @@ class WordleEmbed(EmbedBaseModel):
|
||||||
return emojis
|
return emojis
|
||||||
|
|
||||||
@overrides
|
@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()
|
colours = self.colour_code_game()
|
||||||
|
|
||||||
embed = discord.Embed(colour=discord.Colour.blue(), title="Wordle")
|
embed = discord.Embed(colour=discord.Colour.blue(), title="Wordle")
|
||||||
|
@ -102,15 +104,16 @@ class WordleEmbed(EmbedBaseModel):
|
||||||
|
|
||||||
rows = [" ".join(row) for row in emojis]
|
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):
|
for i, guess in enumerate(self.game.guesses):
|
||||||
rows[i] += f" ||{guess.upper()}||"
|
rows[i] += f" ||{guess.upper()}||"
|
||||||
|
|
||||||
embed.description = "\n\n".join(rows)
|
|
||||||
|
|
||||||
# If the game is over, reveal the word
|
# If the game is over, reveal the word
|
||||||
if self.game.is_game_over(self.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())
|
embed.set_footer(text=footer())
|
||||||
|
|
||||||
return embed
|
return embed
|
||||||
|
|
Loading…
Reference in New Issue