Skip to content

Commit 67f2228

Browse files
committed
games.py: Fix price showing Free for non-free games
1 parent e9cdd4f commit 67f2228

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

modules/games.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -277,18 +277,21 @@ async def _games_search(self, interaction: discord.Interaction, query: str):
277277

278278
lines = []
279279
for platform, price in prices.items():
280-
msrp = price['msrp'] / 100 if price['msrp'] else None
281-
curr = price['price'] / 100 if price['price'] else None
282-
283-
if curr and msrp and curr < msrp:
284-
discount = (1 - curr / msrp) * 100
285-
lines.append(f"{platform}: ~~${msrp:.2f}~~ ${curr:.2f} *(-{discount:.0f}%)*")
280+
msrp = price['msrp'] / 100 if price['msrp'] is not None else None
281+
curr = price['price'] / 100 if price['price'] is not None else None
282+
283+
if curr is not None and msrp and curr < msrp:
284+
if curr != 0:
285+
discount = (1 - curr / msrp) * 100
286+
lines.append(f"{platform}: ~~${msrp:.2f}~~ ${curr:.2f} *(-{discount:.0f}%)*")
287+
else:
288+
lines.append(f"{platform}: ~~${msrp:.2f}~~ Free *(-100%)*")
289+
elif curr == 0:
290+
lines.append(f"{platform}: Free")
286291
elif curr:
287292
lines.append(f"{platform}: ${curr:.2f}")
288293
elif msrp:
289294
lines.append(f"{platform}: ${msrp:.2f}")
290-
else:
291-
lines.append(f"{platform}: Free")
292295

293296
if lines:
294297
s = "" if len(prices) == 1 else "s"

0 commit comments

Comments
 (0)