Skip to content

Commit ff9f32e

Browse files
authored
Merge pull request #4 from notsniped/currencyframework-update-2
Add `deposit` command, to let users add cash into their bank account.
2 parents 0647d9a + e4de6db commit ff9f32e

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

main.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,5 +241,29 @@ async def warn(ctx:SlashContext, user):
241241
save()
242242
await ctx.send(embed=discord.Embed(description=f'All warnings have been cleared for {user}.'))
243243

244+
@slash.slash(
245+
name='deposit',
246+
description='Deposits a specified amount of cash into the bank.',
247+
options=[
248+
create_option(name='amount', description='Specify an amount to deposit (leave blank for max)', option_type=4, required=False)
249+
]
250+
)
251+
async def deposit(ctx:SlashContext, amount=None):
252+
if amount == None:
253+
amount = currency["wallet"][str(user.id)]
254+
elif amount <= 0:
255+
await ctx.reply('The amount you want to deposit must be more than `0` coins!', hidden=True)
256+
return
257+
elif amount > currency["wallet"][str(user.id)]:
258+
await ctx.reply('The amount you want to deposit must not be more than what you have in your wallet!', hidden=True)
259+
return
260+
else:
261+
pass
262+
currency["wallet"][str(user.id)] -= int(amount)
263+
currency["bank"][str(user.id)] += int(amount)
264+
await ctx.send(f'You deposited `{amount}` coins to your bank account.')
265+
save()
266+
267+
244268
# Initialization
245269
client.run(api.auth.token)

0 commit comments

Comments
 (0)