-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathformatters.py
86 lines (56 loc) · 2.9 KB
/
formatters.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import discord
def format_app_details(app_data: dict):
steam_appid = app_data.get('steam_appid')
embed_msg = discord.embeds.Embed(
title='App details', description='Details about this app.', url=f'https://store.steampowered.com/app/{steam_appid}')
embed_msg.set_thumbnail(url=app_data.get('header_image'))
app_dict = {
'name': app_data.get('name'),
'pricing': {
'original_price_formatted': app_data.get('price_overview').get('initial_formatted'),
'final_price_formatted': app_data.get('price_overview').get('final_formatted')
},
'developers': app_data.get('developers'),
'publishers': app_data.get('publishers'),
'platforms': app_data.get('platforms')
}
for key in app_dict.keys():
txt = ''
if key == 'pricing':
embed_msg.add_field(name='Original Price:', value=app_dict.get(
key).get('original_price_formatted'), inline=False)
embed_msg.add_field(name='Final Price:', value=app_dict.get(
key).get('final_price_formatted'), inline=False)
elif key == 'developers' or key == 'publishers':
for company_name in app_data.get(key):
txt += f'{company_name}\n'
embed_msg.add_field(
name=f'{key.capitalize()}:', value=txt, inline=False)
elif key == 'platforms':
for platform_key in app_data.get(key).keys():
if app_data.get(key).get(platform_key) == True:
txt += f'{platform_key.capitalize()} '
embed_msg.add_field(name="Platforms:", value=txt, inline=False)
else:
embed_msg.add_field(
name=f'{key.capitalize()}:', value=app_dict.get(key), inline=False)
# add a blank space between fields to improve readability
embed_msg.add_field(name=" ", value= "")
return embed_msg
def format_embed_offers_msg(embed_title: str, embed_description: str, offers_list: list):
embed_msg = discord.embeds.Embed(
title=embed_title, description=embed_description)
embed_msg.set_thumbnail(url='https://cdn.mos.cms.futurecdn.net/4JETjErxBnB2jNSwnrLkyQ.jpg')
for offer in offers_list:
if type(offer) == dict:
title = f':small_blue_diamond: **{offer.get("name")}**'
og_price = f'{offer.get("price_overview").get("initial_formatted")}'
discount = f'{offer.get("price_overview").get("discount_percent")}'
final_price = f'{offer.get("price_overview").get("final_formatted")}'
price_info = f'~~{og_price}~~ - **{final_price}** __**({discount}% OFF)**__'
embed_msg.add_field(name=title, value=price_info, inline=False)
# add a blank space between fields to improve readability
embed_msg.add_field(name=" ", value= "")
else:
continue
return embed_msg