From 2a8bfb4d6fec41b5db3079cf5e231a743f1ca613 Mon Sep 17 00:00:00 2001 From: diamante0018 Date: Tue, 4 Mar 2025 11:12:11 +0100 Subject: [PATCH] feat(tasks): add embed for sales --- bot/tasks.py | 37 +++++++++++++++++++++++++++++-------- patterns.json | 4 ++++ 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/bot/tasks.py b/bot/tasks.py index 9b1524d..dd12c55 100644 --- a/bot/tasks.py +++ b/bot/tasks.py @@ -51,11 +51,17 @@ class SteamSaleChecker(commands.Cog): return price_info = data.get("price_overview", {}) + header_image = data.get("header_image", None) if not price_info: - await channel.send( - f"{game_name} is currently unavailable for purchase." + embed = discord.Embed( + title=game_name, + description="{game_name} is currently unavailable for purchase.", + color=discord.Color.red(), ) + embed.set_thumbnail(url=header_image if header_image else "") + await channel.send(embed=embed) + return original_price = price_info.get("initial", 0) / 100 @@ -64,14 +70,29 @@ class SteamSaleChecker(commands.Cog): store_url = f"https://store.steampowered.com/app/{app_id}/" if discount_percent > 0: - message = ( - f"**{game_name} is on sale!**\n" - f"Original Price: **${original_price:.2f}**\n" - f"Discounted Price: **${discounted_price:.2f}** (**-{discount_percent}%**)\n" - f"[View on Steam]({store_url})\n" + embed = discord.Embed( + title=f"{game_name} is on Sale!", + description=f"-{discount_percent}% OFF!", + color=discord.Color.green(), ) - await channel.send(message) + embed.set_thumbnail(url=header_image if header_image else "") + embed.add_field( + name="Original Price", + value=f"~~${original_price:.2f}~~", + inline=True, + ) + embed.add_field( + name="Discounted Price", + value=f"**${discounted_price:.2f}**", + inline=True, + ) + embed.add_field( + name="Steam Store", + value=f"[View on Steam]({store_url})", + inline=False, + ) + await channel.send(embed=embed) except requests.RequestException as e: print(f"Error fetching Steam sale data for {game_name}: {e}") diff --git a/patterns.json b/patterns.json index 061fde0..7d1d8b7 100644 --- a/patterns.json +++ b/patterns.json @@ -298,5 +298,9 @@ { "regex": "cocaine", "response": "https://cdn.discordapp.com/attachments/1160511084143312959/1345511700648038501/image.png" + }, + { + "regex": "alterwater", + "response": "https://media3.giphy.com/media/v1.Y2lkPTc5MGI3NjExbWRtYXgwZnBpMnlpOTIyZm5mOXlhNGE4cmdpcnBiYW42NDBlcGljbCZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/BotoBC44860YjP1aEk/giphy.gif" } ] \ No newline at end of file