mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2026-05-27 17:16:44 -04:00
Add [p]bank add/sub subcommands (#6740)
Co-authored-by: Jakub Kuczys <me@jacken.men>
This commit is contained in:
@@ -44,6 +44,32 @@ bank
|
|||||||
|
|
||||||
Base command to manage the bank.
|
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:
|
.. _economy-command-bank-balance:
|
||||||
|
|
||||||
""""""""""""
|
""""""""""""
|
||||||
@@ -98,6 +124,32 @@ Examples:
|
|||||||
- ``<to>`` The user to set the currency of.
|
- ``<to>`` The user to set the currency of.
|
||||||
- ``<creds>`` The amount of currency to set their balance to.
|
- ``<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:
|
.. _economy-command-bank-transfer:
|
||||||
|
|
||||||
"""""""""""""
|
"""""""""""""
|
||||||
|
|||||||
@@ -286,6 +286,68 @@ class Economy(commands.Cog):
|
|||||||
else:
|
else:
|
||||||
await ctx.send(msg)
|
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()
|
@guild_only_check()
|
||||||
@commands.command()
|
@commands.command()
|
||||||
async def payday(self, ctx: commands.Context):
|
async def payday(self, ctx: commands.Context):
|
||||||
|
|||||||
Reference in New Issue
Block a user