feat(tasks): add embed for sales

This commit is contained in:
2025-03-04 11:12:11 +01:00
parent d6df8fcf4f
commit 2a8bfb4d6f
2 changed files with 33 additions and 8 deletions

View File

@@ -51,11 +51,17 @@ class SteamSaleChecker(commands.Cog):
return return
price_info = data.get("price_overview", {}) price_info = data.get("price_overview", {})
header_image = data.get("header_image", None)
if not price_info: if not price_info:
await channel.send( embed = discord.Embed(
f"{game_name} is currently unavailable for purchase." 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 return
original_price = price_info.get("initial", 0) / 100 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}/" store_url = f"https://store.steampowered.com/app/{app_id}/"
if discount_percent > 0: if discount_percent > 0:
message = ( embed = discord.Embed(
f"**{game_name} is on sale!**\n" title=f"{game_name} is on Sale!",
f"Original Price: **${original_price:.2f}**\n" description=f"-{discount_percent}% OFF!",
f"Discounted Price: **${discounted_price:.2f}** (**-{discount_percent}%**)\n" color=discord.Color.green(),
f"[View on Steam]({store_url})\n"
) )
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: except requests.RequestException as e:
print(f"Error fetching Steam sale data for {game_name}: {e}") print(f"Error fetching Steam sale data for {game_name}: {e}")

View File

@@ -298,5 +298,9 @@
{ {
"regex": "cocaine", "regex": "cocaine",
"response": "https://cdn.discordapp.com/attachments/1160511084143312959/1345511700648038501/image.png" "response": "https://cdn.discordapp.com/attachments/1160511084143312959/1345511700648038501/image.png"
},
{
"regex": "alterwater",
"response": "https://media3.giphy.com/media/v1.Y2lkPTc5MGI3NjExbWRtYXgwZnBpMnlpOTIyZm5mOXlhNGE4cmdpcnBiYW42NDBlcGljbCZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/BotoBC44860YjP1aEk/giphy.gif"
} }
] ]