Fix bug in poke current, fix bug in whois

pull/10/head
Stijn De Clercq 2020-11-22 00:30:26 +01:00
parent cd4dcbaeb5
commit 0085882148
3 changed files with 11 additions and 4 deletions

View File

@ -170,7 +170,7 @@ class ModCommands(commands.Cog):
created_local = timeFormatters.epochToDate(user.created_at.timestamp())
embed.add_field(name="Account Aangemaakt", value="{}\n({} Geleden)".format(
embed.add_field(name="Account Aangemaakt", value="{}\n({} geleden)".format(
created_local["date"], timeFormatters.diffYearBasisString(round(created_local["dateDT"].timestamp()))
), inline=False)

View File

@ -58,7 +58,7 @@ class Poke(commands.Cog):
@poke.command(name="Current")
async def current(self, ctx):
p = poke.get()
pokedTimeStamp = datetime.datetime.fromtimestamp(int(p[1]))
pokedTimeStamp = timeFormatters.epochToDate(int(p[1]))["dateDT"]
timeString = timeFormatters.diffDayBasisString(pokedTimeStamp)
await ctx.send("Het is al **{}** aan **{}**.".format(timeString, self.utilsCog.getDisplayName(ctx, p[0])))

View File

@ -82,7 +82,6 @@ def diffYearBasisString(timestamp):
timestamp = epochToDate(timestamp)["dateDT"]
now = dateTimeNow()
diff = dateutil.relativedelta.relativedelta(now, timestamp)
timeList = []
# Don't add obsolete info such as "0 days", ...
@ -98,10 +97,18 @@ def diffYearBasisString(timestamp):
if diff.days != 0:
timeList.append("{} {}".format(diff.days, getPlural(diff.days, "days")))
timeString = ", ".join(timeList[:-1])
timeString = ""
if not timeList:
return "Minder dan een dag"
if len(timeList) > 1:
timeString = ", ".join(timeList[:-1])
if len(timeString) > 0:
timeString += " en "
timeString += timeList[-1]
return timeString