Add [p]bank add/sub subcommands (#6740)

Co-authored-by: Jakub Kuczys <me@jacken.men>
This commit is contained in:
Evanroby
2026-05-23 07:07:58 +02:00
committed by GitHub
parent 08a6a1d2c9
commit f72346e993
2 changed files with 119 additions and 5 deletions
+57 -5
View File
@@ -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:
""""""""""""
@@ -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:
"""""""""""""
@@ -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**
+62
View File
@@ -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**
- `<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):