def updateCard(self, trainer):
dailyDiff = await self.getDiff(trainer, 1)
level=trainer.level
embed=discord.Embed(timestamp=dailyDiff.new_date, colour=int(trainer.team().colour.replace("#", ""), 16))
try:
embed.set_author(name=trainer.username, icon_url=trainer.account().discord().avatar_url)
except:
embed.set_author(name=trainer.username)
embed.add_field(name='Level', value=level.level)
if level.level != 40:
embed.add_field(name='XP', value='{:,} / {:,}'.format(trainer.update.xp-level.total_xp,level.xp_required))
else:
embed.add_field(name='Total XP', value='{}'.format(humanize.intword(trainer.update.xp)))
if dailyDiff.change_xp and dailyDiff.change_time:
gain = '{:,} since {}. '.format(dailyDiff.change_xp, humanize.naturalday(dailyDiff.old_date))
if dailyDiff.change_time.days>1:
gain += "That's {:,} xp/day.".format(round(dailyDiff.change_xp/dailyDiff.change_time.days))
embed.add_field(name='Gain', value=gain)
if trainer.goal_daily and dailyDiff.change_time.days>0:
dailyGoal = trainer.goal_daily
embed.add_field(name='Daily completion', value='{}% towards {:,}'.format(pycent.percentage(dailyDiff.change_xp/max(1,dailyDiff.change_time.days), dailyGoal), dailyGoal))
if trainer.goal_total and trainer.goal_total!=0:
totalGoal = trainer.goal_total
else:
totalGoal = None
if totalGoal:
totalDiff = await self.getDiff(trainer, 7)
embed.add_field(name='Goal remaining', value='{:,} out of {}'.format(totalGoal-totalDiff.new_xp, humanize.intword(totalGoal)))
if totalDiff.change_time.seconds>=1:
eta = lambda x, y, z: round(x/(y/z))
eta = eta(totalGoal-totalDiff.new_xp, totalDiff.change_xp, totalDiff.change_time.total_seconds())
eta = totalDiff.new_date+datetime.timedelta(seconds=eta)
embed.add_field(name='Goal ETA', value=humanize.naturaltime(eta.replace(tzinfo=None)))
if totalDiff.change_time.total_seconds()<583200:
embed.description = "ETA may be inaccurate. Using {} of data.".format(humanize.naturaldelta(totalDiff.change_time))
embed.set_footer(text="Total XP: {:,}".format(dailyDiff.new_xp))
return embed
评论列表
文章目录