Untitled
unknown
python
2 years ago
3.6 kB
5
Indexable
async def scheduled_command(): while True: try: response = requests.get( "https://store-site-backend-static.ak.epicgames.com/freeGamesPromotions").text titles = json.loads(response) f2 = open("nextweek.txt", "r") nextweek = int(f2.read()) f2.close() time_now = int(time.time()) target_time = str(dt_time(hour=23, minute=3, second=0)) target_time_now = str(datetime.now().time()) if time_now >= int(nextweek) - 1000 and target_time_now[0:5] == "15:00": channel = bot.get_channel(847938702345109515) await channel.send("<@&847939354978811924>") for item in titles['data']['Catalog']['searchStore']['elements']: name = item['title'] price = item['price']['totalPrice']['fmtPrice']['discountPrice'] key_images = item['keyImages'] offer = item['offerMappings'] link = item['catalogNs']['mappings'] for slug in link: url = slug.get('pageSlug') oldprice = item['price']['totalPrice']['fmtPrice']['originalPrice'] offer = item['price']['lineOffers'] link = 'https://store.epicgames.com/en-US/p/'+url date = None for image in key_images: if image.get('type') == 'OfferImageWide': image_url = image.get('url') for k in offer: rules = k["appliedRules"] for x in rules: date = x["endDate"] if date == None: pass else: t = datetime( int(date[0:4]), int(date[5:7]), int(date[8:10]), int(date[11:13]), int(date[14:16])) count = str(calendar.timegm(t.timetuple())) embed = discord.Embed( color=discord.Color.green()) embed.add_field(name=name, value="~~"+oldprice+"~~ **FREE**" + "\n Ends <t:"+count+":R> \n[Claim Game]("+link+") ") embed.set_image(url=image_url) embed.set_footer(text="Bot by Her0") embed.set_author(name="Epic Games Store", icon_url="https://i.imgur.com/ANplrW5.png", url="https://store.epicgames.com/en-US/free-games") if price == "0" and name != "PAYDAY 2": f2 = open("nextweek.txt", "w") f2.write(str(count)) f2.close() messageembed = await channel.send(embed=embed, silent=True) await messageembed.add_reaction("🔥") await messageembed.add_reaction("➖") await messageembed.add_reaction("🗑️") await asyncio.sleep(60) except Exception as e: print(e)
Editor is loading...