mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -05:00
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:
parent
9e1f358f82
commit
6ddaff6260
1
changelog.d/economy/3438.bugfix.rst
Normal file
1
changelog.d/economy/3438.bugfix.rst
Normal 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.
|
||||
@ -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(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user