From d6de9c1b94558fd675380e4d39389aadda4a9647 Mon Sep 17 00:00:00 2001 From: Danstr5544 <73479857+Danstr5544@users.noreply.github.com> Date: Fri, 29 Jan 2021 20:50:22 +0000 Subject: [PATCH] Add a way to reset rolepayday amounts (#4758) * Add a way to reset rolepayday amounts * Totally not fixing a typo... * Jack found a Typo Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com> * Max line length Compliancy Thanks Jack (again lol) Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com> * Including rolepaydayamount changes in docs Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com> --- docs/cog_guides/economy.rst | 2 +- redbot/cogs/economy/economy.py | 37 ++++++++++++++++++++++++---------- 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/docs/cog_guides/economy.rst b/docs/cog_guides/economy.rst index b22520734..fd20f7398 100644 --- a/docs/cog_guides/economy.rst +++ b/docs/cog_guides/economy.rst @@ -352,7 +352,7 @@ economyset rolepaydayamount **Description** -Set the amount earned each payday for a role. +Set the amount earned each payday for a role. Setting to 0 will remove the custom payday for that role instead. Only available when not using a global bank. diff --git a/redbot/cogs/economy/economy.py b/redbot/cogs/economy/economy.py index 9ec55959b..fcb4d53e5 100644 --- a/redbot/cogs/economy/economy.py +++ b/redbot/cogs/economy/economy.py @@ -976,6 +976,7 @@ class Economy(commands.Cog): @economyset.command() async def rolepaydayamount(self, ctx: commands.Context, role: discord.Role, creds: int): """Set the amount earned each payday for a role. + Set to `0` to remove the payday amount you set for that role. Only available when not using a global bank. @@ -989,23 +990,37 @@ class Economy(commands.Cog): """ guild = ctx.guild max_balance = await bank.get_max_balance(ctx.guild) - if creds <= 0 or creds > max_balance: + if creds >= max_balance: return await ctx.send( - _("Amount must be greater than zero and less than {maxbal}.").format( - maxbal=humanize_number(max_balance) - ) + _( + "The bank requires that you set the payday to be less than" + " its maximum balance of {maxbal}." + ).format(maxbal=humanize_number(max_balance)) ) credits_name = await bank.get_currency_name(guild) if await bank.is_global(): await ctx.send(_("The bank must be per-server for per-role paydays to work.")) else: - await self.config.role(role).PAYDAY_CREDITS.set(creds) - await ctx.send( - _( - "Every payday will now give {num} {currency} " - "to people with the role {role_name}." - ).format(num=humanize_number(creds), currency=credits_name, role_name=role.name) - ) + if creds <= 0: # Because I may as well... + default_creds = await self.config.guild(guild).PAYDAY_CREDITS() + await self.config.role(role).clear() + await ctx.send( + _( + "The payday value attached to role has been removed. " + "Users with this role will now receive the default pay " + "of {num} {currency}." + ).format(num=humanize_number(default_creds), currency=credits_name) + ) + else: + await self.config.role(role).PAYDAY_CREDITS.set(creds) + await ctx.send( + _( + "Every payday will now give {num} {currency} " + "to people with the role {role_name}." + ).format( + num=humanize_number(creds), currency=credits_name, role_name=role.name + ) + ) @economyset.command() async def registeramount(self, ctx: commands.Context, creds: int):