Skip to content

Commit 596d80e

Browse files
authored
Merge pull request #79 from PyBotDevs/new-command-donate
Add `/donate` command
2 parents 1d0b03a + 61bb83d commit 596d80e

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

main.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,6 +1021,39 @@ async def osugame(ctx:SlashContext):
10211021
embed.set_footer(text='Powered by PRAW')
10221022
await ctx.send(embed = embed)
10231023

1024+
@slash.slash(
1025+
name='donate',
1026+
description="Donate money to whoever you want",
1027+
options=[
1028+
create_option(name='id', description="The ID of the user you are donating to", option_type=3, required=True),
1029+
create_option(name='amount', description="How much do you want to donate?", option_type=4, required=True)
1030+
]
1031+
)
1032+
async def donate(ctx:SlashContext, id:str, amount):
1033+
if plugins.economy:
1034+
reciever_info = client.get_user(int(id))
1035+
if id not in currency["wallet"]: return await ctx.reply("Unfortunately, we couldn't find that user in our server. Try double-checking the ID you've provided.", hidden=True)
1036+
# Prevent self-donations
1037+
if id == ctx.author.id: return await ctx.reply("You can't donate to yourself stupid.", hidden=True)
1038+
# Check for improper amount argument values
1039+
if amount < 1: return await ctx.reply("The amount has to be greater than `1`!", hidden=True)
1040+
elif amount > 1000000000: return await ctx.reply("You can only donate less than 1 billion coins!", hidden=True)
1041+
elif amount > currency["wallet"][str(ctx.author.id)]: return await ctx.reply("You're too poor to be donating that much money lmao")
1042+
# If no improper values, proceed with donation
1043+
try:
1044+
currency["wallet"][str(id)] += amount
1045+
currency["wallet"][str(ctx.author.id)] -= amount
1046+
save()
1047+
except Exception as e: return await ctx.reply(e)
1048+
localembed = discord.Embed(title="Donation Successful", description=f"You successfully donated {amount} coins to {reciever_info.name}!", color=discord.Color.green())
1049+
localembed.add_field(name="Your ID", value=ctx.author.id, inline=True)
1050+
localembed.add_field(name="Reciever's ID", value=id, inline=True)
1051+
localembed2 = discord.Embed(title="You Recieved a Donation!", description=f"{ctx.author} donated {amount} coins to you!", color=discord.Color.green())
1052+
localembed2.add_field(name="Their ID", value=ctx.author.id, inline=True)
1053+
localembed2.add_field(name="Your ID", value=id, inline=True)
1054+
await ctx.send(embed=localembed)
1055+
await reciever_info.send(embed=localembed2)
1056+
10241057
# Initialization
10251058
utils.ping.host()
10261059
client.run(api.auth.token)

0 commit comments

Comments
 (0)