Skip to content

Commit c988bd1

Browse files
authored
fix error obtaining product slug for url (#33)
1 parent 3862f5f commit c988bd1

File tree

4 files changed

+907
-10
lines changed

4 files changed

+907
-10
lines changed

bot/README.md

+6
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ A script to check Epic Games store weekly for new freebies, pushes notifications
1111

1212
## Usage
1313

14+
### Local
15+
```
16+
npm install
17+
npm run start
18+
```
19+
1420
### Docker
1521
```
1622
docker run -e SEND_UPCOMING=true -e DISCORD_WEBHOOK='foobar' \

bot/package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bot/src/epic_games.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ async function check_store() {
2424
const title = game.title
2525
console.log(game.title)
2626
console.log(game.catalogNs.mappings)
27-
const slug = game.catalogNs.mappings != null && game.catalogNs.mappings.length > 0 ? game.catalogNs.mappings[0].pageSlug : "error"
27+
const slug = game.productSlug != null ? game.productSlug : game.catalogNs.mappings != null && game.catalogNs.mappings.length > 0 ? game.catalogNs.mappings[0].pageSlug : "error"
2828
console.log(slug)
2929
var original_price = game.price.totalPrice.fmtPrice.originalPrice
30-
original_price = parseFloat(original_price.replace(/[^0-9\.]+/g,"")).toFixed(2).toString()
30+
original_price = parseFloat(original_price.replace(/[^0-9\.]+/g, "")).toFixed(2).toString()
3131
const publisher = game.seller.name
3232
const description = game.description
3333
var thumbnail = game.keyImages != null ? game.keyImages[0].url : "error"
@@ -70,14 +70,14 @@ async function check_store() {
7070
}
7171

7272
// Skip any false-positives (may just be on sale, or non-updated)
73-
if (game.price.totalPrice.discountPrice != 0){
73+
if (game.price.totalPrice.discountPrice != 0) {
7474
skip = true
7575
}
76-
77-
if (!sendUpcoming && end_date == null){
76+
77+
if (!sendUpcoming && end_date == null) {
7878
skip = true
7979
}
80-
80+
8181
if (!skip) {
8282
const found_game = {
8383
title: title,
@@ -93,7 +93,7 @@ async function check_store() {
9393
}
9494
})
9595
const ordered_game_list = game_list.sort(
96-
function(a, b) {
96+
function (a, b) {
9797
return (a.end_date === null) - (b.end_date === null) || +(a > b) || -(a < b);
9898
})
9999

@@ -181,7 +181,7 @@ check_store().then(games => {
181181
games.forEach((game) => {
182182
var webhooks = discord_webhook.split(",")
183183
webhooks.forEach((webhook) => {
184-
if(notify){
184+
if (notify) {
185185
send_discord(game, webhook)
186186
}
187187
})

0 commit comments

Comments
 (0)