Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @client.command()
- async def submit(ctx, member: discord.Member, score, oscore):
- with open('profiles.json') as f:
- profiles = json.load(f)
- if member.id == ctx.author.id:
- await ctx.send("wtf r u trying to do... u didnt 1v1 urself right?")
- elif str(ctx.author.id) not in profiles:
- await ctx.send(f"You have not registered. Do {prefix}register.")
- elif str(member.id) not in profiles:
- await ctx.send(f"This user has not registered. Tell them to do {prefix}register.")
- else:
- embed=discord.Embed(color=0x008040)
- embed.add_field(name="Score Submitted", value=f"{score} (You) - {oscore} ({member.mention})", inline=False)
- embed.set_footer(text="Tell your opponent to check their DMs!")
- await ctx.send(embed=embed)
- # DM OPPONENT FOR CONFIRMATION
- embed=discord.Embed(color=0x0080c0)
- embed.add_field(name="Incoming score submission!", value=f"Received from {ctx.author.name}", inline=False)
- embed.add_field(name=f"{oscore} (You) - {score} (Them)", value="React to confirm the match. This dialog will time out in 2 minutes.", inline=True)
- embed.set_footer(text="DO NOT SUBMIT THIS MATCH AGAIN. ONLY ONE SUBMISSION AND CONFIRMATION IS REQUIRED.")
- cmessage = await member.send(embed=embed)
- await cmessage.add_reaction("👍")
- def check(reaction, user):
- return user == member and str(reaction.emoji) == '👍'
- try:
- reaction, user = await client.wait_for('reaction_add', timeout=120.0, check=check)
- except asyncio.TimeoutError:
- await member.send("You ran out of time. Tell your opponent to submit again (or submit it yourself).")
- await ctx.author.send("Your opponent did not confirm the match in time.")
- else:
- await member.send("Confirmed match.")
- await ctx.author.send("Your opponent confirmed the match!")
- #update stats time
- with open('profiles.json') as f:
- profiles = json.load(f)
- # UPDATE STATS
- submitter = str(ctx.author.id)
- confirmer = str(member.id)
- profiles[submitter]["games"] += 1
- profiles[confirmer]["games"] += 1
- if score > oscore:
- profiles[submitter]["wins"] += 1
- profiles[confirmer]["losses"] += 1
- elif oscore > score:
- profiles[confirmer]["wins"] += 1
- profiles[submitter]["losses"] += 1
- else:
- profiles[submitter]["wins"] += 1
- profiles[confirmer]["wins"] += 1
- profiles[submitter]["kills"] += int(score)
- profiles[submitter]["deaths"] += int(oscore)
- profiles[confirmer]["kills"] += int(oscore)
- profiles[confirmer]["deaths"] += int(score)
- # POINTS TIME!
- profiles[submitter]["points"] += int(score) * 10
- profiles[confirmer]["points"] += int(oscore) * 10
- with open('profiles.json', 'w', encoding='utf-8') as f:
- json.dump(profiles, f, ensure_ascii=False, indent=4)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement