diff --git a/docs/cog_guides/economy.rst b/docs/cog_guides/economy.rst index 498f376c3..240b6fe62 100644 --- a/docs/cog_guides/economy.rst +++ b/docs/cog_guides/economy.rst @@ -38,12 +38,38 @@ bank .. code-block:: none - [p]bank + [p]bank **Description** Base command to manage the bank. +.. _economy-command-bank-add: + +"""""""" +bank add +"""""""" + +.. note:: |admin-lock| + +**Syntax** + +.. code-block:: none + + [p]bank add + +**Description** + +Add currency to a user's bank account. + +Example: + - ``[p]bank add @Twentysix 100`` - Increases balance by 100 + +**Arguments** + +- ```` The user to give currency to. +- ```` The amount of currency to add. + .. _economy-command-bank-balance: """""""""""" @@ -98,6 +124,32 @@ Examples: - ```` The user to set the currency of. - ```` The amount of currency to set their balance to. +.. _economy-command-bank-sub: + +"""""""" +bank sub +"""""""" + +.. note:: |admin-lock| + +**Syntax** + +.. code-block:: none + + [p]bank sub + +**Description** + +Remove currency from a user's bank account. + +Example: + - ``[p]bank sub @Twentysix 50`` - Decreases balance by 50 + +**Arguments** + +- ```` The user to remove currency from. +- ```` The amount of currency to remove. + .. _economy-command-bank-transfer: """"""""""""" @@ -136,7 +188,7 @@ economyset .. code-block:: none - [p]economyset + [p]economyset **Description** @@ -228,7 +280,7 @@ economyset showsettings .. code-block:: none - [p]economyset showsettings + [p]economyset showsettings **Description** @@ -343,7 +395,7 @@ payday .. code-block:: none - [p]payday + [p]payday **Description** @@ -361,7 +413,7 @@ payouts .. code-block:: none - [p]payouts + [p]payouts **Description** diff --git a/redbot/cogs/economy/economy.py b/redbot/cogs/economy/economy.py index 29732a930..be814a878 100644 --- a/redbot/cogs/economy/economy.py +++ b/redbot/cogs/economy/economy.py @@ -286,6 +286,68 @@ class Economy(commands.Cog): else: await ctx.send(msg) + @bank.is_owner_if_bank_global() + @commands.admin_or_permissions(manage_guild=True) + @_bank.command(name="add") + async def _add(self, ctx: commands.Context, to: discord.Member, creds: positive_int): + """Add currency to a user's bank account. + + Example: + - `[p]bank add @Twentysix 100` - Increases balance by 100 + + **Arguments** + + - `` The user to give currency to. + - `` The amount of currency to add. + """ + author = ctx.author + currency = await bank.get_currency_name(ctx.guild) + + try: + await bank.deposit_credits(to, creds) + except (ValueError, errors.BalanceTooHigh) as e: + await ctx.send(str(e)) + else: + await ctx.send( + _("{author} added {num} {currency} to {user}'s account.").format( + author=author.display_name, + num=humanize_number(creds), + currency=currency, + user=to.display_name, + ) + ) + + @bank.is_owner_if_bank_global() + @commands.admin_or_permissions(manage_guild=True) + @_bank.command(name="sub", aliases=["subtract"]) + async def _sub(self, ctx: commands.Context, to: discord.Member, creds: positive_int): + """Remove currency from a user's bank account. + + Example: + - `[p]bank sub @Twentysix 50` - Decreases balance by 50 + + **Arguments** + + - `` The user to remove currency from. + - `` The amount of currency to remove. + """ + author = ctx.author + currency = await bank.get_currency_name(ctx.guild) + + try: + await bank.withdraw_credits(to, creds) + except ValueError as e: + await ctx.send(str(e)) + else: + await ctx.send( + _("{author} removed {num} {currency} from {user}'s account.").format( + author=author.display_name, + num=humanize_number(creds), + currency=currency, + user=to.display_name, + ) + ) + @guild_only_check() @commands.command() async def payday(self, ctx: commands.Context):