-1

I'm quite new to coding and stuff and i wanted to code a discord bot, that sends a message with the weekly free games. I copied the free games example from https://github.com/SD4RK/epicstore_api/tree/master/examples for that with a few changes (I try to learn it by reading other peoples codes and trying to understand it) but it always gives me games that are no longer free, but were free before. I tried different things like del free_games or free_games.clear() at the end of the whole function, but both didn't work. The best thing was free_games.remove(game) at the end of the for game in free_games part, but than it gave only the old games that are no longer free out and not the current. I hope someone can help me with that.

Edit okay here the code:

def main():
    api = EpicGamesStoreAPI()
    free_games = api.get_free_games()['data']['Catalog']['searchStore']['elements']
    for game in free_games:
        game_name = game['title']
        #not important
        print('{} ({}) is FREE now.'.format(game_name, game_price))
  • 1
    post your code so we can see what your trying – JBirdVegas Dec 22 '20 at 16:31
  • your description is useless if you don't show code. And maybe problem is not code but simply there is no more free games. Better show minimal working code with real data - so we could simply copy and run it – furas Dec 22 '20 at 16:34
  • As I said you can find it on https://github.com/SD4RK/epicstore_api/blob/master/examples/free_games_example.py i didnt change that much, the for that relevant parts are the same – Lord of Darkness Dec 22 '20 at 17:41
  • on Stackoverflow you should add code inquestion, not as link. Later someone may remove code from link and all question will be useless for other users. Besides it is long code and on Stackoverflow you should show this part which really makes problem and gives error message and then we may try to resolve this small problem. It is not place to analyze all long code in some external script. – furas Dec 22 '20 at 18:14
  • @furas okay, edited – Lord of Darkness Dec 22 '20 at 19:10

1 Answers1

0

You have to read free_games again, and replace the old list. Like that

free_games = getFreeGames() # At the execution time, free_games list should be the list of currently free games
shareGames(free_games)

# ...
# after some time when someone would ask again about free games
free_games = getFreeGames()
shareGames(free_games)

Also you can make an interval to share it periodically every some time, check this