modularise network level
original commit message: add network level Please enter the commit message for your changes. Lines starting with '#' will be ignored, and an empty message aborts the commit. Date: Sun Jun 6 17:32:14 2021 -0400 On branch master Your branch is ahead of 'origin/master' by 1 commit. (use "git push" to publish your local commits) Changes to be committed: modified: bot.py modified: hypixel_bot_tools/__init__.py
This commit is contained in:
parent
c11682477c
commit
01f41e8f9c
3
bot.py
3
bot.py
|
@ -48,7 +48,6 @@ async def ping(ctx):
|
|||
await pong.edit(content=f':ping_pong: Pong! ({delta} ms)\n*Finding Discord message edit latency...*')
|
||||
hi2 = time.time()
|
||||
await pong.edit(content=f':ping_pong: Pong! ({delta} ms)\n*Discord message edit latency: {hi2 - hi1}*')
|
||||
def sqrt(num): return num ** 0.5
|
||||
@bot.command(name="hypixel",aliases=("h","stats"))
|
||||
async def hypixel(ctx,player,ConvertToUUID=True):
|
||||
"""
|
||||
|
@ -70,7 +69,7 @@ async def hypixel(ctx,player,ConvertToUUID=True):
|
|||
em.add_field(name=_("UUID"),value=getuuid(player),inline=True)
|
||||
em.add_field(name=_("Rank"), value=contents['rank'],inline=True)
|
||||
networkEXP = contents['networkExp']
|
||||
em.add_field(name=_("Network Level"),value=f"{(sqrt((2 * networkEXP) + 30625) / 50) - 2.5} ({_('raw')} {contents['networkExp']})",inline=True)
|
||||
em.add_field(name=_("Network Level"),value=f"{round(RawXPToLevel(networkEXP),2)} ({_('raw')} {contents['networkExp']})",inline=True)
|
||||
await thing.edit(embed=em, content="Player data down below.")
|
||||
# }}}
|
||||
# {{{ Run bot
|
||||
|
|
|
@ -91,6 +91,14 @@ def guild(HYPIXEL_API_KEY,data,TYPE):
|
|||
req = json.loads(requests.get(f"https://api.hypixel.net/guild?key={HYPIXEL_API_KEY}&{TYPE}={data}").text)
|
||||
if req['success'] is False: raise UnknownError(req)
|
||||
return req
|
||||
def sqrt(num): return num ** 0.5
|
||||
def RawXPToLevel(xp):
|
||||
"""
|
||||
Accepts the number of Xp (API: player.networkExp), and returns the level.
|
||||
Quite a long number, you may want to round it.
|
||||
Kudos to https://hypixel.net/threads/convert-network-exp-to-network-level.1912930 for the formula :D
|
||||
"""
|
||||
return (sqrt((2 * xp) + 30625) / 50) - 2.5
|
||||
def RestOfTheFunctions():
|
||||
"""
|
||||
The rest of the functions are still a work in progress.
|
||||
|
|
Loading…
Reference in New Issue