Payday should store the last time it was used so it can be compared to the cooldown value rather than using a cooldown deco that won't reset if cooldown goes lower (#3496)

* Payday #3438 Changed next_payday to last_payday

* Created towncrier entry

* [PR #3496] Requested changes

* rm .vs
This commit is contained in:
Hugo Hedlund 2020-02-14 15:13:18 +01:00 committed by GitHub
parent 9e1f358f82
commit 6ddaff6260
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 5 deletions

View File

@ -0,0 +1 @@
Changes next_payday to last_payday. last_payday stores the latest time the command runned successfully, allows the command to dynamicly change with the PAYDAY_TIME variable, by checking if last_payday + PAYDAY_TIME >= current time.

View File

@ -349,7 +349,11 @@ class Economy(commands.Cog):
cur_time = calendar.timegm(ctx.message.created_at.utctimetuple())
credits_name = await bank.get_currency_name(ctx.guild)
if await bank.is_global(): # Role payouts will not be used
next_payday = await self.config.user(author).next_payday()
# Gets the latest time the user used the command successfully and adds the global payday time
next_payday = (
await self.config.user(author).next_payday() + await self.config.PAYDAY_TIME()
)
if cur_time >= next_payday:
try:
await bank.deposit_credits(author, await self.config.PAYDAY_CREDITS())
@ -365,8 +369,8 @@ class Economy(commands.Cog):
)
)
return
next_payday = cur_time + await self.config.PAYDAY_TIME()
await self.config.user(author).next_payday.set(next_payday)
# Sets the current time as the latest payday
await self.config.user(author).next_payday.set(cur_time)
pos = await bank.get_leaderboard_position(author)
await ctx.send(
@ -392,7 +396,12 @@ class Economy(commands.Cog):
).format(author=author, time=dtime)
)
else:
next_payday = await self.config.member(author).next_payday()
# Gets the users latest successfully payday and adds the guilds payday time
next_payday = (
await self.config.member(author).next_payday()
+ self.config.guild(guild).PAYDAY_TIME()
)
if cur_time >= next_payday:
credit_amount = await self.config.guild(guild).PAYDAY_CREDITS()
for role in author.roles:
@ -415,7 +424,10 @@ class Economy(commands.Cog):
)
)
return
next_payday = cur_time + await self.config.guild(guild).PAYDAY_TIME()
# Sets the latest payday time to the current time
next_payday = cur_time
await self.config.member(author).next_payday.set(next_payday)
pos = await bank.get_leaderboard_position(author)
await ctx.send(