Skip to content

Commit

Permalink
CheapGames update
Browse files Browse the repository at this point in the history
  • Loading branch information
GitGinocchio committed Dec 22, 2024
1 parent e5c8736 commit dc1da70
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
1 change: 1 addition & 0 deletions notes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ https://apidocs.cheapshark.com/
https://www.freetogame.com/api-doc
https://www.gamerpower.com/api-read
https://cataas.com/
https://random-word-api.herokuapp.com/word?lang=it&number=2&length=5

Ignoring exception in command <nextcord.application_command.SlashApplicationSubcommand object at 0x7f4e663187a0>:
Traceback (most recent call last):
Expand Down
21 changes: 15 additions & 6 deletions src/commands/games/CheapGames.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,12 +353,16 @@ async def send_giveaway_update(self, update_config : dict):

url = f'{baseurl}{endpoint}{'?' if len(params) > 0 else ''}{'&'.join(params)}'

logger.info(f"Fetching games at: {url}")

games : list[dict] = await asyncget(url)

n_send : int = 0 # Number of games to send
for game in games:
if str(game["id"]) in saved_giveaways and game["published_date"] == saved_giveaways[str(game["id"])]:
# Here we are checking if this giveaway is already registered
continue
n_send += 1

saved_giveaways[str(game["id"])] = game["published_date"]

Expand All @@ -369,12 +373,17 @@ async def send_giveaway_update(self, update_config : dict):
ui = GiveawayGame(game)

message = await channel.send(embed=ui, view=ui)

try:
await message.publish()
except Exception as e:
print(e)
break # Send only one game at a time

if message.channel.is_news():
try:
await message.publish()
except Exception as e:
logger.exception(e)

if n_send >= 10: # Send only 10 games at a tine
break

#break # Send only one game at a time

async def send_deal_update(self, update_config : dict):
return ""
Expand Down

0 comments on commit dc1da70

Please sign in to comment.