def handle(old_username: str, new_username: str,
           world_folder_location: str) -> None:
    try:
        validate_usernames_syntax(old_username, new_username)
    except e:
        exit(1)

    old_user_data, new_user_data = GetPlayerData(old_username), GetPlayerData(
        new_username)

    try:
        validate_user_data(old_user_data, new_user_data)
    except e:
        exit(1)

    old_user_uuid, new_user_uuid = UUID(old_user_data.uuid), UUID(
        new_user_data.uuid)

    for old_path in Path(world_folder_location).rglob(f'*{old_user_uuid}*'):
        new_path = Path(f'{old_path.parent}\\{new_user_uuid}{old_path.suffix}')
        new_path.unlink(missing_ok=True)
        copyfile(old_path, new_path)
        print(f'Copying {old_path} to {new_path}')

    print('Success!')
Exemple #2
0
async def stats(ctx, username):
    timestamp = None
    if len(sys.argv) > 1:
        identifier = sys.argv[1]

        if len(sys.argv) > 2:
            if sys.argv[2].isdigit():
                timestamp = int(sys.argv[2])

    if username is None:
        username = ctx.author.name
    identifier = username
    if is_valid_minecraft_username(identifier) or is_valid_mojang_uuid(
            identifier):
        player = GetPlayerData(identifier, timestamp)
        uuid = player.uuid
        name = player.username
        skin_url = f"https://mc-heads.net/body/{uuid}"
    else:
        return await ctx.send(
            "There is no minecraft player with that username!")
    player = Player(api_key, uuid)
    stats = player.getBasicStats()
    embed = discord.Embed(title=f"{name}'s Basic Stats")
    embed.add_field(
        name="Stats",
        value=
        f'``Most Recent Game``: {stats["mostRecentGameType"]}\n``Network EXP``: {stats["networkExp"]}\n``Karma``: {stats["karma"]}\n``Current Pet``: {stats["currentPet"]}\n``Particle Pack``: {stats["particlePack"]}\n``Chat Channel``: {stats["channel"]}\n``Total Rewards Claimed``: {stats["totalRewards"]}\n``Total Daily Rewards Claimed``: {stats["totalDailyRewards"]}'
    )
    embed.set_thumbnail(url=skin_url)
    embed.set_footer(
        text=
        "You can also retrieve stats for specific games using h!<game> <username> (not all games are supported right now)"
    )
    await ctx.send(embed=embed)
Exemple #3
0
    async def pearl(self, ctx, *, content):
        """Pearls a player"""
        if len(content.split(" ")) > 1:
            players = []
            for p in content.split(" ")[:2]:
                if GetPlayerData(p) and hasattr(GetPlayerData(p), 'username'):
                    players.append(GetPlayerData(p).username)
                elif not re.match('^(\w|d){3,16}', p):
                    await ctx.channel.send("Invalid usernames supplied")
                    return
                else:
                    players.append(re.match('^(\w|d){3,30}', p).group(0))

            date = datetime.datetime.today().strftime('%m/%d/%Y')
            if len(content.split(" ")) > 2 and re.match(
                    "\d{1,2}\/\d{1,2}\/\d{1,4}",
                    content.split(" ")[2]):
                date = re.match("\d{1,2}\/\d{1,2}\/\d{1,4}",
                                content.split(" ")[2]).group(0)

            params = functools.partial(draw_pearl_image, players[0],
                                       players[1], date)
            await self.bot.loop.run_in_executor(None, params)
            bot_message = await ctx.channel.send(
                file=discord.File("resources/output.png"))

            with open('resources/pearl locations.txt', 'r') as file:
                locations = json.load(file)
            await asyncio.sleep(1)
            locations[players[0].lower()] = bot_message.jump_url
            with open('resources/pearl locations.txt', 'w') as file:
                json.dump(locations, file)
Exemple #4
0
def draw_chart_image(chart_data, chart_code):
    x_axis = chart_data[str(chart_code)]["x_axis"]
    y_axis = chart_data[str(chart_code)]["y_axis"]

    # DRAW TEXT
    background = Image.open("resources/ImageMeme/Chart/grid2500.png")
    font = ImageFont.truetype("resources/fonts/NotoSans-Bold.ttf", 128)
    img_txt = Image.new('L', font.getsize(y_axis))
    draw_txt = ImageDraw.Draw(img_txt)
    draw_txt.text((0, 0), y_axis, font=font, fill=255)
    t = img_txt.rotate(90, expand=1)
    background.paste(
        ImageOps.colorize(t, (0, 0, 0), (0, 0, 0)),
        (-10, int((background.height - font.getsize(y_axis)[0]) / 2)), t)
    draw = ImageDraw.Draw(background)
    draw.text((int((background.width - font.getsize(x_axis)[0]) / 2), 2320),
              x_axis, (0, 0, 0),
              font=font)

    # DRAW faces
    for player_name in chart_data[str(chart_code)]['chart_data'].keys():
        x_cord_total = 0
        y_cord_total = 0
        for discord_id in chart_data[str(chart_code)]['chart_data'][str(
                player_name)]:
            x_cord_total += float(chart_data[str(chart_code)]['chart_data'][
                str(player_name)][str(discord_id)]["x_coord"])
            y_cord_total += float(chart_data[str(chart_code)]['chart_data'][
                str(player_name)][str(discord_id)]["y_coord"])

        total = len(
            chart_data[str(chart_code)]['chart_data'][str(player_name)])
        coords = [x_cord_total / total, y_cord_total / total]
        face_width = 120
        fixed_coords = [
            int((coords[0] / 100) * background.width - (face_width / 2)),
            int((background.height - ((coords[1] / 100) * background.height)) -
                (face_width / 2))
        ]
        if GetPlayerData(player_name).valid:
            if path.exists("resources/playerheads/" + str(player_name) +
                           ".png"):
                pass
            else:
                r = requests.get("https://mc-heads.net/avatar/" +
                                 GetPlayerData(player_name).uuid + "/" +
                                 str(face_width) + ".png")
                with open("resources/playerheads/" + str(player_name) + ".png",
                          'wb') as f:
                    f.write(r.content)
            playertopaste = Image.open("resources/playerheads/" + player_name +
                                       ".png")
            background.paste(playertopaste, tuple(fixed_coords))
    background.save('resources/output.png', "PNG")
Exemple #5
0
def draw_weezer(players):
    to_send = []

    drawn_players = ["", "", "", ""]
    joiners = ""
    rect_corners = [[(3, 300), (78, 94)], [(78, 300), (148, 107)],
                    [(153, 300), (222, 94)], [(226, 300), (294, 100)]]
    background = Image.open("resources/weezer template.png")
    draw = ImageDraw.Draw(background)

    players = players[:4]
    for p in players:
        if not GetPlayerData(p).valid:
            to_send.append(
                discord.utils.escape_markdown(discord.utils.escape_mentions(
                    p)) +
                " does not appear to be a valid player. Are you sure you typed correctly?"
            )
        else:
            selected = False
            while not selected:
                r = random.randint(-1, 3)
                if drawn_players[r] == "":
                    drawn_players[r] = GetPlayerData(p).username
                    draw.rectangle((rect_corners[r][0], rect_corners[r][1]),
                                   fill="#00acea")
                    selected = True

    out_2 = None
    if len(players) > len(to_send):
        for x in range(0, len(drawn_players)):
            if drawn_players[x] != "":
                r = requests.get(
                    "https://mc-heads.net/player/" +
                    GetPlayerData(drawn_players[x]).uuid + "/" +
                    str((rect_corners[x][0][1] - rect_corners[x][1][1]) / 2) +
                    ".png")
                with open("resources/test.png", 'wb') as f:
                    f.write(r.content)
                playertopaste = Image.open("resources/test.png")
                background.paste(
                    playertopaste,
                    (rect_corners[x][0][0], rect_corners[x][1][1]),
                    mask=playertopaste)
                joiners += ", " + drawn_players[x]
        background.save('resources/output.png', "PNG")
        if sum([x != "" for x in drawn_players]) > 1:
            k = joiners.rfind(", ")
            joiners = joiners[:k] + " and" + joiners[k + 1:]

        out_2 = "**Oh my God" + joiners + " joined weezer!**"
    return to_send, out_2
Exemple #6
0
async def uhc(ctx, username):
    timestamp = None
    if len(sys.argv) > 1:
        identifier = sys.argv[1]

        if len(sys.argv) > 2:
            if sys.argv[2].isdigit():
                timestamp = int(sys.argv[2])

    if username is None:
        username = ctx.author.name
    identifier = username
    if is_valid_minecraft_username(identifier) or is_valid_mojang_uuid(
            identifier):
        player = GetPlayerData(identifier, timestamp)
        uuid = player.uuid
        name = player.username
        skin_url = f"https://mc-heads.net/body/{uuid}"
    else:
        return await ctx.send(
            "There is no minecraft player with that username!")
    player = Player(api_key, uuid)
    try:
        stats = player.getUHCStats()
    except:
        return await ctx.send("This player hasn't played UHC!")
    embed = discord.Embed(title=f"{name}'s UHC Stats")
    embed.set_thumbnail(url=skin_url)
    embed.add_field(
        name="General",
        value=
        f'``Kills``: {stats["kills"]}\n``Deaths``: {stats["deaths"]}\n``KDR``: {stats["kdr"]}\n``Wins``: {stats["wins"]}\n'
    )
    try:
        equippedKit = stats["equippedKit"].lower().replace("_",
                                                           " ").capitalize()
    except:
        equippedKit = "None"
    embed.add_field(
        name="Miscellaneous",
        value=
        f'``Coins``: {stats["coins"]}\n``Heads Eaten``: {stats["heads_eaten"]}\n``Ultimates Crafted``: {stats["ultimates_crafted"]}\n``Equipped Kit``: {equippedKit}'
    )
    embed.set_footer(
        text=
        "Note: All of this data is from the Hypixel API. If there are any inaccuracies, it is not my fault."
    )
    await ctx.send(embed=embed)
    del player
Exemple #7
0
async def skywars(ctx, username):
    timestamp = None
    if len(sys.argv) > 1:
        identifier = sys.argv[1]

        if len(sys.argv) > 2:
            if sys.argv[2].isdigit():
                timestamp = int(sys.argv[2])

    if username is None:
        username = ctx.author.name
    identifier = username
    if is_valid_minecraft_username(identifier) or is_valid_mojang_uuid(
            identifier):
        player = GetPlayerData(identifier, timestamp)
        try:
            uuid = player.uuid
        except:
            return await ctx.send(
                "There is no minecraft player with that username.")
        name = player.username
        skin_url = f"https://mc-heads.net/body/{uuid}"
    else:
        return await ctx.send(
            "There is no minecraft player with that username!")
    player = Player(api_key, uuid)
    try:
        stats = player.getSkywarsStats()
    except:
        return await ctx.send("This player hasn't played skywars!")
    embed = discord.Embed(title=f"{name}'s Skywars Stats")
    embed.set_thumbnail(url=skin_url)
    embed.add_field(
        name="General",
        value=
        f'``Level``: {stats["levelFormatted"]}\n``Games Played``: {stats["games_played_skywars"]}\n``Kills``: {stats["kills"]}\n``Deaths``: {stats["deaths"]}\n``KDR``: {stats["kdr"]}\n``Wins``: {stats["wins"]}\n``Losses``: {stats["losses"]}\n``Win Rate``: {stats["win_rate"]}\n``Bow Accuracy``: {stats["bow_accuracy"]}'
    )
    embed.add_field(
        name="Miscellaneous",
        value=
        f'``Coins``: {stats["coins"]}\n``Current Souls``: {stats["souls"]}\n``Total Collected Souls``: {stats["souls_gathered"]}\n``Total EXP``: {stats["skywars_experience"]}\n``Fastest Win``: {stats["fastest_win"]} seconds\n``Chests Opened``: {stats["chests_opened"]}\n``Rage Quits``: {stats["quits"]}'
    )
    embed.set_footer(
        text=
        "Note: All of this data is from the Hypixel API. If there are any inaccuracies, it is not my fault."
    )
    await ctx.send(embed=embed)
    del player
Exemple #8
0
    def pop_players(self):
        self.playerList.clear()
        path = serverPath + "world\\playerdata\\"
        username = []
        for root, dirs, files in os.walk(path):
            for file in files:
                if file.endswith(".dat") and len(file) == 40:
                    uuid = file[0:36]
                    uuid_short = uuid.replace('-', '')
                    if uuid in names:
                        username.append(names[uuid])
                    else:
                        Player = GetPlayerData(uuid_short)
                        if Player.valid is True:
                            name = Player.username
                            username.append(name)
                            names[uuid] = name
                        else:
                            username.append(uuid)

        self.playerList.addItems(username)
        self.playerList.itemClicked.connect(self.update_player)
        if self.loggerRunning() == 1:
            self.logButt.setEnabled(False)
            self.logButt.setText("Running")
        else:
            self.logButt.setEnabled(True)
Exemple #9
0
async def edit(ctx, chart_code, playername, xpos, ypos):
    '''Edits a chart with given chart code, Minecraft username, x coord and y coord.'''
    with open("resources/chart_creator.txt") as json_file:
        chart_data = json.load(json_file)
    try:
        if float(xpos) > 100 or float(xpos) < 0 or float(ypos) > 100 or float(
                ypos) < 0:
            await ctx.send("input must range between 0 to 100")
            return
    except ValueError:
        await ctx.send("Must be number")
        return
    if not GetPlayerData(playername).valid:
        await ctx.send("this is not a valid playername")
        return
    if str(chart_code) in chart_data.keys():
        if not str(playername) in chart_data[chart_code]['chart_data'].keys():
            chart_data[chart_code]['chart_data'][str(playername)] = {}

        chart_data[chart_code]['chart_data'][str(playername)][str(
            ctx.author.id)] = {
                "x_coord": str(xpos),
                "y_coord": str(ypos)
            }

        with open("resources/chart_creator.txt", "w") as json_file:
            json.dump(chart_data, json_file)

        # optional : show chart after posting
        params = functools.partial(draw_chart, chart_data, chart_code)
        run_draw = await bot.loop.run_in_executor(None, params)
        await ctx.channel.send(file=discord.File('resources/output.png'))
    else:
        await ctx.send("chart not found")
Exemple #10
0
async def bedwars(ctx, username):
    timestamp = None
    if len(sys.argv) > 1:
        identifier = sys.argv[1]

        if len(sys.argv) > 2:
            if sys.argv[2].isdigit():
                timestamp = int(sys.argv[2])

    if username is None:
        username = ctx.author.name
    identifier = username
    if is_valid_minecraft_username(identifier) or is_valid_mojang_uuid(
            identifier):
        player = GetPlayerData(identifier, timestamp)
        uuid = player.uuid
        name = player.username
        skin_url = f"https://mc-heads.net/body/{uuid}"
    else:
        return await ctx.send(
            "There is no minecraft player with that username!")
    player = Player(api_key, uuid)
    try:
        stats = player.getBedwarsStats()
    except:
        return await ctx.send("This player hasn't played bedwars!")
    embed = discord.Embed(title=f"{name}'s Bedwars Stats")
    embed.set_thumbnail(url=skin_url)
    embed.add_field(
        name="General",
        value=
        f'``Games Played``: {stats["games_played_bedwars"]}\n``Kills``: {stats["kills_bedwars"]}\n``Final Kills``: {stats["final_kills_bedwars"]}\n``Deaths``: {stats["deaths_bedwars"]}\n``KDR``: {stats["kdr"]}\n``Beds Broken``: {stats["beds_broken_bedwars"]}\n``Wins``: {stats["wins_bedwars"]}\n``Losses``: {stats["losses_bedwars"]}\n``Win Rate``: {stats["win_rate"]}\n``Win Streak``: {stats["winstreak"]}'
    )
    embed.add_field(
        name="Miscellaneous",
        value=
        f'``Experience``: {stats["Experience"]}\n``Beds Lost``: {stats["beds_lost_bedwars"]}\n``Items purchased``: {stats["_items_purchased_bedwars"]}\n``Total Resources Collected``: {stats["resources_collected_bedwars"]}\n``Iron Collected``: {stats["iron_resources_collected_bedwars"]}\n``Gold Collected``: {stats["gold_resources_collected_bedwars"]}\n``Diamonds Collected``: {stats["diamond_resources_collected_bedwars"]}\n``Emeralds Collected``: {stats["emerald_resources_collected_bedwars"]}'
    )
    embed.set_footer(
        text=
        "Note: All of this data is from the Hypixel API. If there are any inaccuracies, it is not my fault."
    )
    await ctx.send(embed=embed)
    del player
Exemple #11
0
async def hungergames(ctx, username):
    timestamp = None
    if len(sys.argv) > 1:
        identifier = sys.argv[1]

        if len(sys.argv) > 2:
            if sys.argv[2].isdigit():
                timestamp = int(sys.argv[2])

    if username is None:
        username = ctx.author.name
    identifier = username
    if is_valid_minecraft_username(identifier) or is_valid_mojang_uuid(
            identifier):
        player = GetPlayerData(identifier, timestamp)
        uuid = player.uuid
        name = player.username
        skin_url = f"https://mc-heads.net/body/{uuid}"
    else:
        return await ctx.send(
            "There is no minecraft player with that username!")
    player = Player(api_key, uuid)
    stats = player.getHungerGamesStats()
    embed = discord.Embed(title=f"{name}'s Hunger Games Stats")
    embed.add_field(
        name="General",
        value=
        f'``Wins``: {stats["wins"]}\n``Kills``: {stats["kills"]}\n``Deaths``: {stats["deaths"]}\n``KDR``: {stats["kdr"]}'
    )
    embed.add_field(
        name="Miscellaneous",
        value=
        f'``Coins``: {stats["coins"]}\n``Damage Dealt``: {stats["damage"]}\n``Damage Received``: {stats["damage_taken"]}\n``Chests Opened``: {stats["chests_opened"]}'
    )
    embed.set_thumbnail(url=skin_url)
    embed.set_footer(
        text=
        "Note: All of this data is from the Hypixel API. If there are any inaccuracies, it is not my fault."
    )
    await ctx.send(embed=embed)
    del player
Exemple #12
0
async def dont_care(ctx, content):
    if not GetPlayerData(content).valid:
        await ctx.channel.send(
            discord.utils.escape_markdown(
                discord.utils.escape_mentions(content)) +
            " does not appear to be a valid player. Are you sure you typed correctly?"
        )
    else:
        params = functools.partial(draw_dont_care, content)
        run_draw = await bot.loop.run_in_executor(None, params)
        bot_message = await ctx.channel.send(
            file=discord.File("resources/output.png"))
Exemple #13
0
 async def grimreminder(self, ctx, player):
     """Draws a grim reminder"""
     if not GetPlayerData(player).valid:
         await ctx.channel.send(
             discord.utils.escape_markdown(
                 discord.utils.escape_mentions(player)) +
             " does not appear to be a valid player. Are you sure you typed correctly?"
         )
         return
     params = functools.partial(draw_grimreminder_image, player)
     await self.bot.loop.run_in_executor(None, params)
     await ctx.channel.send(file=discord.File('resources/output.png'))
Exemple #14
0
 async def dontcare(self, ctx, content):
     """Shows everyone how little you care"""
     if not GetPlayerData(content).valid:
         await ctx.channel.send(
             discord.utils.escape_markdown(
                 discord.utils.escape_mentions(content)) +
             " does not appear to be a valid player. Are you sure you typed correctly?"
         )
     else:
         params = functools.partial(draw_dontcare_image, content)
         await self.bot.loop.run_in_executor(None, params)
         await ctx.channel.send(file=discord.File("resources/output.png"))
Exemple #15
0
 async def getalong(self, ctx, player1, player2):
     """Draws two players in the 'get along' shirt"""
     players = [player1, player2]
     for x in players:
         if not GetPlayerData(x).valid:
             await ctx.channel.send(
                 discord.utils.escape_markdown(
                     discord.utils.escape_mentions(x)) +
                 " does not appear to be a valid player. Are you sure you typed correctly?"
             )
             return
     params = functools.partial(draw_getalong_image, players)
     await self.bot.loop.run_in_executor(None, params)
     await ctx.channel.send(file=discord.File('resources/output.png'))
Exemple #16
0
async def getalong(ctx, player1, player2):
    """First we botted farms, then we botted vaults, now we finally have an opportunity to bot world peace."""
    players = [player1, player2]
    for x in players:
        if not GetPlayerData(x).valid:
            await ctx.channel.send(
                discord.utils.escape_markdown(discord.utils.escape_mentions(
                    x)) +
                " does not appear to be a valid player. Are you sure you typed correctly?"
            )
            return
    params = functools.partial(draw_getalong, players)
    msg = await bot.loop.run_in_executor(None, params)
    await ctx.channel.send(file=discord.File('resources/output.png'))
Exemple #17
0
def pop_players():
    path = serverPath + "world\\playerdata\\"
    username = []
    for root, dirs, files in os.walk(path):
        for file in files:
            if file.endswith(".dat") and len(file) == 40:
                uuid = file[0:36]
                uuid_short = uuid.replace('-', '')
                if uuid in names:
                    username.append(names[uuid])
                else:
                    Player = GetPlayerData(uuid_short)
                    if Player.valid is True:
                        name = Player.username
                        username.append(name)
                        names[uuid] = name
                    else:
                        username.append(uuid)
Exemple #18
0
async def whois(ctx: commands.Context, user: str):
    ch: discord.TextChannel = ctx.channel
    try:
        player = GetPlayerData(user)
        player.uuid
    except (Exception):
        await ch.send("Error invalid Username " + user)
        return
    
    cursor = db.cursor()
    cursor.execute(f"SELECT * FROM users WHERE minecraft_uuid = ?",
                   [str(player.uuid)])
    rows = cursor.fetchall()
    cursor.close()
    db.commit()
    if rows:
        disc_user: discord.User = await client.fetch_user(int(rows[0][0]))
        await ch.send(user + " is " + disc_user.mention)
    else:
        await ch.send(user + " isn't whitelisted on this server")
Exemple #19
0
# Else, ask for a identifier by userinput
else:
    print("Please enter a username or UUID: ")
    identifier = input()

### Is the identifier a valid value?
if is_valid_minecraft_username(identifier) or is_valid_mojang_uuid(identifier):
    # Print the type of the identifier
    if is_valid_minecraft_username(identifier):
        print('Valid username')
    if is_valid_mojang_uuid(identifier):
        print('Valid UUID')

    ### Obtaining the playerinformation using our module
    player = GetPlayerData(identifier, timestamp)
    # Check if the request was valid and the user exists
    if player.valid is True:
        # Getting UUID
        uuid = player.uuid
        # Getting real Username
        name = player.username

        # Print everything
        print('UUID: ' + uuid)
        print('correct name: ' + name)

    # Error message
    else:
        print("That player was not found.")
Exemple #20
0
from mcuuid.api import GetPlayerData

player = GetPlayerData("489178c645bb4f3382f110f7f0d7381a")

print(player.username)
if player.valid is True:
    uuid = player.uuid
    print(player.username)

print("Hello")
Exemple #21
0
def add_to_whitelist(username: str, disc_user: discord.User):
    command("whitelist add " + username)
    sql = "INSERT INTO users(discord_id, minecraft_uuid) VALUES(?,?)"
    uuid = GetPlayerData(username).uuid
    cursor = db.cursor()
    cursor.execute(sql, (str(disc_user.id), str(uuid)))
    input("Bad Query Syntax -or- Bad Table Name")
    exit()

# Fetches all data associated with query
tabledata = cursor.fetchall()

# Will go to second row when for loop starts
row = 0

# ***Display to console and writing to Excel sheet***
for entry in tabledata:
    # THIS IF CHECK CAN BE DELETED - HANDLED EARLIER
    # MCUUID does not accept full UUID, so it must be trimmed with replace function
    trimuuid = entry[0].replace("-", "")
    try:
        player = GetPlayerData(trimuuid)
    except:
        print("MCUUID ERROR AT - " + trimuuid)
        continue
    # Restart each for loop to first column and next row
    column = 0
    row += 1
    # Translates minutes from DB into hours (and rounds to two decimal points)
    tiH = round((int(entry[1] / 60)), 2)
    if player.valid is True:
        print("%s | %s | %d" % (player.uuid, player.username, tiH))
        sheet.write(row, column, player.uuid)
        sheet.write(row, column + 1, player.username)
        sheet.write(row, column + 2, tiH)
    elif player.valid is False:
        print("%s | INVALID UUID | %d" % (player.uuid, tiH))
Exemple #23
0
async def duels(ctx, username, mode=None):
    timestamp = None
    if len(sys.argv) > 1:
        identifier = sys.argv[1]

        if len(sys.argv) > 2:
            if sys.argv[2].isdigit():
                timestamp = int(sys.argv[2])

    if username is None:
        username = ctx.author.name
    identifier = username
    if is_valid_minecraft_username(identifier) or is_valid_mojang_uuid(
            identifier):
        player = GetPlayerData(identifier, timestamp)
        uuid = player.uuid
        name = player.username
        skin_url = f"https://mc-heads.net/body/{uuid}"
    else:
        return await ctx.send(
            "There is no minecraft player with that username!")
    player = Player(api_key, uuid)
    stats = player.getDuelsStats(mode=mode)
    if mode is None:
        embed = discord.Embed(title=f"{name}'s Duels Stats")
        embed.add_field(
            name="General",
            value=
            f'``Games Played``: {stats["games_played_duels"]}\n``Rounds Played``: {stats["rounds_played"]}\n``Melee Swings``: {stats["melee_swings"]}\n``Melee Hits``: {stats["melee_hits"]}\n``Melee Accuracy``: {stats["sword_accuracy"]}\n``Arrows Shot``: {stats["bow_shots"]}\n``Arrows Hit``: {stats["bow_hits"]}\n``Bow Accuracy``: {stats["bow_accuracy"]}'
        )
        embed.add_field(
            name="Miscellaneous",
            value=
            f'``Coins``: {stats["coins"]}\n``Health Regenerated``: {stats["health_regenerated"]}\n``Damage Dealt``: {stats["damage_dealt"]}\n``Blocks Placed``: {stats["blocks_placed"]}'
        )
        embed.set_footer(text="You can also use h!duels <username> [gamemode]")
    elif mode == "sw":
        embed = discord.Embed(title=f"{name}'s Skywars Duels Stats")
        embed.add_field(
            name="General",
            value=
            f'``Rounds Played``: {stats["sw_duel_rounds_played"]}\n``Equipped Kit``: {stats["sw_duels_kit"].replace("_"," ").capitalize()}\n``Bow Shots``: {stats["sw_duel_bow_shots"]}\n``Melee Accuracy``: {stats["sw_duel_sword_accuracy"]}'
        )
        embed.add_field(
            name="Miscellaneous",
            value=
            f'``Health Regenerated``: {stats["sw_duel_health_regenerated"]}\n``Arrows Shot``: {stats["sw_duel_bow_shots"]}\n``Blocks Placed``: {stats["sw_duel_blocks_placed"]}\n``Damage Dealt``: {stats["sw_duel_damage_dealt"]}'
        )
        embed.set_footer(
            text=
            "Hypixel's API changes often is oddly specific, so many of the stats will look horribly wrong and not be the same across other duel types."
        )
    elif mode == "uhc":
        embed = discord.Embed(title=f"{name}'s UHC Duels Stats")
        embed.add_field(
            name="General",
            value=
            f'``Rounds Played``: {stats["uhc_duel_rounds_played"]}\n``Kills``: {stats["uhc_duel_kills"]}\n``Deaths``: {stats["uhc_duel_kills"]}\n``KDR``: {stats["uhc_duel_kdr"]}\n``Wins``: {stats["uhc_duel_wins"]}\n``Losses``: {stats["uhc_duel_losses"]}\n``Win Rate``: {stats["uhc_duel_win_rate"]}\n``Melee Accuracy``: {stats["uhc_duel_sword_accuracy"]}\n``Arrows Shot``: {stats["uhc_duel_bow_shots"]}\n``Arrows Hit``: {stats["uhc_duel_bow_hits"]}\n``Bow Accuracy``: {stats["uhc_duel_bow_accuracy"]}'
        )
        embed.add_field(
            name="Miscellaneous",
            value=
            f'``Health Regenerated``: {stats["uhc_duel_health_regenerated"]}')
        embed.set_footer(
            text=
            "Hypixel's API changes often is oddly specific, so many of the stats will look horribly wrong and not be the same across other duel types."
        )
    elif mode == "classic":
        embed = discord.Embed(title=f"{name}'s Classic Duels Stats")
        embed.add_field(
            name="General",
            value=
            f'``Rounds Played``: {stats["classic_duel_rounds_played"]}\n``Melee Accuracy``: {stats["classic_duel_sword_accuracy"]}\n``Arrows Shot``: {stats["classic_duel_bow_shots"]}\n``Arrows Hit``: {stats["classic_duel_bow_hits"]}\n``Bow Accuracy``: {stats["classic_duel_bow_accuracy"]}'
        )
        embed.add_field(
            name="Miscellaneous",
            value=
            f'``Health Regenerated``: {stats["classic_duel_health_regenerated"]}\n``Damage Dealt``: {stats["classic_duel_damage_dealt"]}'
        )
        embed.set_footer(
            text=
            "Hypixel's API changes often is oddly specific, so many of the stats will look horribly wrong and not be the same across other duel types."
        )
    elif mode == "op":
        embed = discord.Embed(title=f"{name}'s OP Duels Stats")
        embed.add_field(
            name="General",
            value=
            f'``Rounds Played``: {stats["op_duel_rounds_played"]}\n``Deaths``: {stats["op_duel_deaths"]}\n``Wins``: {stats["op_duel_wins"]}\n``Losses``: {stats["op_duel_losses"]}\n``Win Rate``: {stats["op_duel_win_rate"]}\n``Melee Accuracy``: {stats["op_duel_sword_accuracy"]}'
        )
        embed.add_field(
            name="Miscellaneous",
            value=
            f'``Damage Dealt``: {stats["op_duel_damage_dealt"]}\n``Health Regenerated``: {stats["op_duel_health_regenerated"]}'
        )
        embed.set_footer(
            text=
            "Hypixel's API changes often is oddly specific, so many of the stats will look horribly wrong and not be the same across other duel types."
        )
    elif mode == "bridge":
        embed = discord.Embed(title=f"{name}'s Bridge Duels Stats")
        embed.add_field(
            name="General",
            value=
            f'``Rounds Played``: {stats["bridge_doubles_rounds_played"]}\n``Melee Accuracy``: {stats["bridge_doubles_sword_accuracy"]}\n``Arrows Shot``: {stats["bridge_doubles_bow_shots"]}\n``Arrows Hit``: {stats["bridge_doubles_bow_hits"]}\n``Bow Accuracy``: {stats["bridge_doubles_bow_accuracy"]}'
        )
        embed.add_field(
            name="Miscellaneous",
            value=
            f'``Damage Dealt``: {stats["bridge_doubles_damage_dealt"]}\n``Health Regenerated``: {stats["bridge_doubles_damage_dealt"]}\n``Blocks Placed``: {stats["bridge_doubles_blocks_placed"]}'
        )
        embed.set_footer(
            text=
            "Hypixel's API changes often is oddly specific, so many of the stats will look horribly wrong and not be the same across other duel types."
        )
    elif mode == "sumo":
        embed = discord.Embed(title=f"{name}'s Sumo Duels Stats")
        embed.add_field(
            name="General",
            value=
            f'``Rounds Played``: {stats["sumo_duel_rounds_played"]}\n``Kills``: {stats["sumo_duel_kills"]}\n``Deaths``: {stats["sumo_duel_deaths"]}\n``KDR``: {stats["sumo_duel_kdr"]}\n``Wins``: {stats["sumo_duel_wins"]}\n``Losses``: {stats["sumo_duel_losses"]}\n``Win Rate``: {stats["sumo_duel_win_rate"]}\n``Fist Swings``: {stats["sumo_duel_melee_swings"]}\n``Fist Hits``: {stats["sumo_duel_melee_hits"]}\n``Melee Accuracy``: {stats["sumo_duel_sword_accuracy"]}'
        )
        embed.set_footer(
            text=
            "Hypixel's API changes often is oddly specific, so many of the stats will look horribly wrong and not be the same across other duel types."
        )
    else:
        return await ctx.send(
            "Invalid gamemode! Valid gamemodes are ``sw, uhc, classic, bridge, sumo``."
        )
    embed.set_thumbnail(url=skin_url)
    await ctx.send(embed=embed)
    del player