From 94167890cf4807da6b1e653c4599cf0310134ced Mon Sep 17 00:00:00 2001 From: Tino Date: Wed, 9 Oct 2024 07:51:34 -0500 Subject: [PATCH] Add separate Discord webhook for shiny encounters on block list --- .../built_in_plugins/discord_integration.py | 33 ++++++++++++------- modules/config/schemas_v1.py | 2 ++ modules/config/templates/discord.yml | 7 ++++ 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/modules/built_in_plugins/discord_integration.py b/modules/built_in_plugins/discord_integration.py index 6129dc78..75e235e5 100644 --- a/modules/built_in_plugins/discord_integration.py +++ b/modules/built_in_plugins/discord_integration.py @@ -16,7 +16,7 @@ if TYPE_CHECKING: from modules.config.schemas_v1 import DiscordWebhook - from modules.encounter import EncounterInfo + from modules.encounter import EncounterInfo, EncounterValue from modules.pokemon import Pokemon from modules.profiles import Profile @@ -115,18 +115,10 @@ def on_logging_encounter(self, encounter: "EncounterInfo") -> Generator | None: shiny_phase = context.stats.current_shiny_phase # Discord shiny Pokémon encountered - if context.config.discord.shiny_pokemon_encounter.enable and opponent.is_shiny: - block = ( - "\n❌Skipping catching shiny (on catch block list)!" - if opponent.species_name_for_stats in context.config.catch_block - or opponent.species.name in context.config.catch_block - or opponent.species_name_for_stats in context.config.catch_block - else "" - ) - + if context.config.discord.shiny_pokemon_encounter.enable and encounter.value is EncounterValue.Shiny: send_discord_message( webhook_config=context.config.discord.shiny_pokemon_encounter, - content=f"{encounter.type.verb.title()} a shiny ✨ {opponent.species_name_for_stats} ✨! {block}", + content=f"{encounter.type.verb.title()} a shiny ✨ {opponent.species_name_for_stats} ✨!", embed=DiscordMessageEmbed( title=f"Shiny {encounter.type.verb}!", description=f"{opponent.nature.name} {opponent.species_name_for_stats} (Lv. {opponent.level:,}) at {opponent.location_met}!", @@ -144,6 +136,25 @@ def on_logging_encounter(self, encounter: "EncounterInfo") -> Generator | None: ), ) + # Discord shiny on block list encountered + if context.config.discord.blocked_shiny_encounter.enable and encounter.value is EncounterValue.ShinyOnBlockList: + send_discord_message( + webhook_config=context.config.discord.blocked_shiny_encounter, + content=f"{encounter.type.verb.title()} a shiny ✨ {opponent.species_name_for_stats} ✨.\n❌ But this species is on the block list, so it will not be caught. ❌", + embed=DiscordMessageEmbed( + title=f"(Blocked) Shiny {encounter.type.verb}", + description=f"{opponent.nature.name} {opponent.species_name_for_stats} (Lv. {opponent.level:,}) at {opponent.location_met}!", + fields={ + "Shiny Value": f"{opponent.shiny_value:,}", + f"{opponent.species_name_for_stats} Encounters": f"{species_stats.total_encounters:,} ({species_stats.shiny_encounters:,}✨)", + f"{opponent.species_name_for_stats} Phase Encounters": f"{species_stats.phase_encounters:,}", + } + | phase_summary_fields(opponent, shiny_phase), + thumbnail=get_shiny_sprite(opponent), + colour="808080", + ), + ) + # Discord Pokémon encounter milestones if ( context.config.discord.pokemon_encounter_milestones.enable diff --git a/modules/config/schemas_v1.py b/modules/config/schemas_v1.py index 9689a1c9..557d1418 100644 --- a/modules/config/schemas_v1.py +++ b/modules/config/schemas_v1.py @@ -97,6 +97,7 @@ class Discord(BaseConfig): bot_id: str = "PokéBot Gen3" global_webhook_url: str = "" shiny_pokemon_encounter: DiscordWebhook = Field(default_factory=lambda: DiscordWebhook()) + blocked_shiny_encounter: DiscordWebhook = Field(default_factory=lambda: DiscordWebhook()) pokemon_encounter_milestones: DiscordWebhook = Field(default_factory=lambda: DiscordWebhook(interval=10000)) shiny_pokemon_encounter_milestones: DiscordWebhook = Field(default_factory=lambda: DiscordWebhook(interval=5)) total_encounter_milestones: DiscordWebhook = Field(default_factory=lambda: DiscordWebhook(interval=25000)) @@ -112,6 +113,7 @@ def is_anything_enabled(self) -> bool: return ( self.rich_presence or self.shiny_pokemon_encounter.enable + or self.blocked_shiny_encounter.enable or self.pokemon_encounter_milestones.enable or self.shiny_pokemon_encounter_milestones.enable or self.total_encounter_milestones.enable diff --git a/modules/config/templates/discord.yml b/modules/config/templates/discord.yml index 2f54df22..e368c7f7 100644 --- a/modules/config/templates/discord.yml +++ b/modules/config/templates/discord.yml @@ -13,6 +13,13 @@ shiny_pokemon_encounter: ping_id: #webhook_url: +# Shiny Pokémon encounters that were on the block list and will therefore not be caught +blocked_shiny_encounter: + enable: false + ping_mode: + ping_id: + #webhook_url: + # Pokémon encounter milestones pokemon_encounter_milestones: enable: false