Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 57 additions & 5 deletions docs/cog_guides/economy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <to> <creds>

**Description**

Add currency to a user's bank account.

Example:
- ``[p]bank add @Twentysix 100`` - Increases balance by 100

**Arguments**

- ``<to>`` The user to give currency to.
- ``<creds>`` The amount of currency to add.

.. _economy-command-bank-balance:

""""""""""""
Expand Down Expand Up @@ -98,6 +124,32 @@ Examples:
- ``<to>`` The user to set the currency of.
- ``<creds>`` 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 <to> <creds>

**Description**

Remove currency from a user's bank account.

Example:
- ``[p]bank sub @Twentysix 50`` - Decreases balance by 50

**Arguments**

- ``<to>`` The user to remove currency from.
- ``<creds>`` The amount of currency to remove.

.. _economy-command-bank-transfer:

"""""""""""""
Expand Down Expand Up @@ -136,7 +188,7 @@ economyset

.. code-block:: none

[p]economyset
[p]economyset

**Description**

Expand Down Expand Up @@ -228,7 +280,7 @@ economyset showsettings

.. code-block:: none

[p]economyset showsettings
[p]economyset showsettings

**Description**

Expand Down Expand Up @@ -343,7 +395,7 @@ payday

.. code-block:: none

[p]payday
[p]payday

**Description**

Expand All @@ -361,7 +413,7 @@ payouts

.. code-block:: none

[p]payouts
[p]payouts

**Description**

Expand Down
62 changes: 62 additions & 0 deletions redbot/cogs/economy/economy.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,68 @@ async def _set(self, ctx: commands.Context, to: discord.Member, creds: SetParser
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**

- `<to>` The user to give currency to.
- `<creds>` 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**

- `<to>` The user to remove currency from.
- `<creds>` 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):
Expand Down
Loading