Skip to content

Commit af7b264

Browse files
authored
Merge pull request #5 from notsniped/currencyframework-update-3
Add `withdraw` command
2 parents ee4bb55 + 2be96b2 commit af7b264

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

main.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,29 @@ async def deposit(ctx:SlashContext, amount=None):
258258
currency["wallet"][str(user.id)] -= int(amount)
259259
currency["bank"][str(user.id)] += int(amount)
260260
await ctx.send(f'You deposited `{amount}` coins to your bank account.')
261+
262+
@slash.slash(
263+
name='withdraw',
264+
description='Withdraws a specified amount of cash from the bank.',
265+
options=[
266+
create_option(name='amount', description='Specify an amount to withdraw (leave blank for max)', option_type=4, required=False)
267+
]
268+
)
269+
async def withdraw(ctx:SlashContext, amount=None):
270+
if amount == None:
271+
amount = currency["bank"][str(user.id)]
272+
elif amount <= 0:
273+
await ctx.reply('The amount you want to withdraw must be more than `0` coins!', hidden=True)
274+
return
275+
elif amount > currency["bank"][str(user.id)]:
276+
await ctx.reply('The amount you want to withdraw must not be more than what you have in your bank account!', hidden=True)
277+
return
278+
else:
279+
pass
280+
currency["wallet"][str(user.id)] += int(amount)
281+
currency["bank"][str(user.id)] -= int(amount)
282+
await ctx.send(f'You withdrew `{amount}` coins from your bank account.')
283+
save()
261284

262285
@slash.slash(
263286
name='daily',

0 commit comments

Comments
 (0)