diff --git a/database.json b/database.json index 6a64228..0ebc8ac 100644 --- a/database.json +++ b/database.json @@ -1 +1 @@ -"{'806706495466766366': ObservedDict(value={'prefix': '!', 'name': \"Zenn's Dev Portal\", 'join': False}), 'players': ObservedDict(value={'427968672980533269': ObservedDict(value={'scrap': 0, 'trading': '', '806706495466766366': ObservedList(value=['\ud83d\udc51|Legendary|*Crown of the Supreme*|**Overlord**|+4'])}), '187227540962672640': ObservedDict(value={'scrap': 0, 'trading': '', '806706495466766366': ObservedList(value=['\ud83e\udd6f|Epic|Jeweled Erotic|Bagel|+1'])})})}" \ No newline at end of file +"{'players': ObservedDict(value={'427968672980533269': ObservedDict(value={'scrap': 22, 'trading': '', '806706495466766366': ObservedList(value=['\ud83d\udc3b\\u200d\u2744\ufe0f|Uncommon|Sickly|Polar Bear|+0', '\ud83d\udcd5|Epic|Honest|Book|+0', '\ud83d\udca9|Rare|Virulent|Poop|+0', '\ud83c\udffa|Epic|Glowing High Quality|Amphora|+0']), '761036747504484392': ObservedList(value=['\ud83d\udc38|Common|Bawdy|Frog|+1'])}), '187227540962672640': ObservedDict(value={'scrap': 62, 'trading': '', '806706495466766366': ObservedList(value=[])}), '529381965804077067': ObservedDict(value={'scrap': 10, 'trading': '', '806706495466766366': ObservedList(value=['\ud83c\udf48|Common|Ultimate|Melon|+1'])})}), '806706495466766366': ObservedDict(value={'prefix': '!', 'name': \"Zenn's Dev Portal\", 'join': True}), '761036747504484392': ObservedDict(value={'prefix': '!', 'name': 'test this is', 'join': True})}" \ No newline at end of file diff --git a/main.py b/main.py index 19126e3..9d11c6e 100644 --- a/main.py +++ b/main.py @@ -599,27 +599,30 @@ def checkR(reaction, user): if mbr.isnumeric(): if message.guild.get_member(int(mbr)): mbr = message.guild.get_member(int(mbr)) - guild1, count1 = getItem(message.author.id, int(splits[2])) - if str(message.author.id) in db["players"]: - if guild1 != False: - item = db["players"][str(message.author.id)][guild1][count1-1] - del db["players"][str(message.author.id)][guild1][count1-1] - if str(mbr.id) not in db["players"]: - db["players"][str(mbr.id)] = {} - db["players"][str(mbr.id)]["scrap"] = 0 - if guild1 not in db["players"][str(mbr.id)]: - db["players"][str(mbr.id)][guild1] = [] - db["players"][str(mbr.id)][guild1].append(item) - splits = item.split("|") - item = splits[0] +" **["+ splits[1] +"]** "+ splits[2] +" "+ splits[3] +" "+splits[4] - embed = discord.Embed(description="\n"+item+"\n", color=colors[rarities.index(splits[1])]) - embed.set_author(name=message.author.name + " sent", icon_url=message.author.avatar_url) - embed.set_footer(text="to "+mbr.name, icon_url=mbr.avatar_url) - await message.channel.send(embed=embed) + if mbr.id != message.author.id: + guild1, count1 = getItem(message.author.id, int(splits[2])) + if str(message.author.id) in db["players"]: + if guild1 != False: + item = db["players"][str(message.author.id)][guild1][count1-1] + del db["players"][str(message.author.id)][guild1][count1-1] + if str(mbr.id) not in db["players"]: + db["players"][str(mbr.id)] = {} + db["players"][str(mbr.id)]["scrap"] = 0 + if guild1 not in db["players"][str(mbr.id)]: + db["players"][str(mbr.id)][guild1] = [] + db["players"][str(mbr.id)][guild1].append(item) + splits = item.split("|") + item = splits[0] +" **["+ splits[1] +"]** "+ splits[2] +" "+ splits[3] +" "+splits[4] + embed = discord.Embed(description="\n"+item+"\n", color=colors[rarities.index(splits[1])]) + embed.set_author(name=message.author.name + " sent", icon_url=message.author.avatar_url) + embed.set_footer(text="to "+mbr.name, icon_url=mbr.avatar_url) + await message.channel.send(embed=embed) + else: + await error(message, "Item does not exist.") else: - await error(message, "Item does not exist.") + await error(message, "You have no items to give.") else: - await error(message, "You have no items to give.") + await error(message, "You can not give items to yourself.") else: await error(message, "Member not in the guild.") else: @@ -640,32 +643,35 @@ def checkR(reaction, user): if splits[1].isnumeric(): if message.guild.get_member(int(splits[1])): mbr = message.guild.get_member(int(splits[1])) - if splits[2].isnumeric(): - amount = int(splits[2]) - if amount > 0: - if str(message.author.id) in db["players"]: - scrap = db["players"][str(message.author.id)]["scrap"] - if scrap >= amount: - if splits[1] not in db["players"]: - db["players"][str(mbr.id)] = {} - db["players"][str(mbr.id)]["scrap"] = 0 - #gave amount to user - db["players"][str(mbr.id)]["scrap"] = db["players"][str(mbr.id)]["scrap"] + amount - #subtract amount - db["players"][str(message.author.id)]["scrap"] = scrap - amount - #confirmation message - embed = discord.Embed(color=0x000000,description="gave **"+str(amount)+"** "+scrapEmoji + " to:") - embed.set_author(name=message.author.name, icon_url=message.author.avatar_url) - embed.set_footer(text=mbr.name,icon_url=mbr.avatar_url) - await message.channel.send(embed=embed) + if mbr.id != message.author.id: + if splits[2].isnumeric(): + amount = int(splits[2]) + if amount > 0: + if str(message.author.id) in db["players"]: + scrap = db["players"][str(message.author.id)]["scrap"] + if scrap >= amount: + if splits[1] not in db["players"]: + db["players"][str(mbr.id)] = {} + db["players"][str(mbr.id)]["scrap"] = 0 + #gave amount to user + db["players"][str(mbr.id)]["scrap"] = db["players"][str(mbr.id)]["scrap"] + amount + #subtract amount + db["players"][str(message.author.id)]["scrap"] = scrap - amount + #confirmation message + embed = discord.Embed(color=0x000000,description="gave **"+str(amount)+"** "+scrapEmoji + " to:") + embed.set_author(name=message.author.name, icon_url=message.author.avatar_url) + embed.set_footer(text=mbr.name,icon_url=mbr.avatar_url) + await message.channel.send(embed=embed) + else: + await error(message, "You only have "+str(scrap)+scrapEmoji) else: - await error(message, "You only have "+str(scrap)+scrapEmoji) + await error(message, "You do not have any scrap.") else: - await error(message, "You do not have any scrap.") + await error(message, "Please enter an amount above `0`") else: - await error(message, "Please enter an amount above `0`") + await error(message, "Scrap amount should be numeric") else: - await error(message, "Scrap amount should be numeric") + await error(message, "You can not pay yourself.") else: await error(message, "Invalid player mention or ID") else: