diff --git a/AnyConv.com__minecraft-2053886_960_7200.svg b/AnyConv.com__minecraft-2053886_960_7200.svg
new file mode 100644
index 0000000..a80bb45
--- /dev/null
+++ b/AnyConv.com__minecraft-2053886_960_7200.svg
@@ -0,0 +1,9460 @@
+
+
+
diff --git a/bot.py b/bot.py
index 69ba65c..9c69fbc 100644
--- a/bot.py
+++ b/bot.py
@@ -1,8 +1,8 @@
# {{{ Imports
-import discord, requests, json, time
+import discord, requests, json, time, os, hypixel_bot_tools.errors, tempfile
from discord.ext import commands
from hypixel_bot_tools import *
-import hypixel_bot_tools.errors
+from cairosvg import svg2png
hypierror = hypixel_bot_tools.errors
# }}}
# {{{ Get token
@@ -76,8 +76,10 @@ async def hypixel(ctx,player,ConvertToUUID=True):
raise
item[i] = "N/A"
currentStatus_Message = f"{item['gameType']} ({_('mode')} {item['mode']}); {_('on map')} {item['map']}"
+ onlinecolour = "green"
except KeyError:
currentStatus_Message = _("Offline")
+ onlinecolour = "#454545"
for i in ("karma",): #these are fields that might not exist
try:
contents[i]
@@ -87,14 +89,24 @@ async def hypixel(ctx,player,ConvertToUUID=True):
em = discord.Embed(
title=f"{contents['displayname']}'{_('s Hypixel Stats')}",
footer=_("Thanks for using Hypibot!"))
+ val = f"{round(RawXPToLevel(contents['networkExp']),2)} ({_('raw')} {int(contents['networkExp'])})"
em.add_field(name=_("UUID"),value=getuuid(player),inline=True)
em.add_field(name=_("Rank"), value=contents['rank'],inline=True)
- em.add_field(name=_("Network Level"),value=f"{round(RawXPToLevel(contents['networkExp']),2)} ({_('raw')} {contents['networkExp']})",inline=True)
+ em.add_field(name=_("Network Level"),value=val,inline=True)
em.add_field(name=_("Karma"),value=contents['karma'],inline=True)
em.add_field(name=_("Friends"),value=lenfriends,inline=True)
em.add_field(name="\u200b",value="\u200b",inline=True)#newline; \u200b is a zero width space that is allowed by dcord
em.add_field(name=_("Online?"),value=statusAPI_Message,inline=True)
em.add_field(name=_("Current Game"),value=currentStatus_Message,inline=True)
+ with open("AnyConv.com__minecraft-2053886_960_7200.svg") as file:
+ svg = file.read().format(uuid=getuuid(player), userhtml="""{rank} {displayname}""".format(rank=contents['rank'], displayname=contents['displayname']), exp=val, karma=contents['karma'], friends=lenfriends,
+ onlinehtml=f'{currentStatus_Message}')
+ with tempfile.TemporaryDirectory() as tmp:
+ path = os.path.join(tmp, 'png.pngpng.png') #https://stackoverflow.com/a/45803022/9654083
+ svg2png(bytestring=svg, write_to=path) #https://stackoverflow.com/questions/6589358/convert-svg-to-png-in-python
+ with open(path, "rb") as file: #https://stackoverflow.com/questions/60913131/how-to-send-a-image-with-discord-py
+ file = discord.File(file, filename=path)
+ await ctx.send(file=file)
await thing.edit(embed=em, content="Player data down below.")
@bot.command()
async def bedwars(ctx, player, ConvertToUUID=True):
diff --git a/hypixel_bot_tools/__init__.py b/hypixel_bot_tools/__init__.py
index 44b5016..2343722 100644
--- a/hypixel_bot_tools/__init__.py
+++ b/hypixel_bot_tools/__init__.py
@@ -18,7 +18,7 @@ def translaterank(rank):
#the following if statements are exceptions
if rank == "SUPERSTAR": rank = "MVP_PLUS_PLUS"
if rank == "YOUTUBER": rank = "YOUTUBE"
- if rank is None: return "Regular"
+ if rank is None: return "(None)"
rank = rank.replace("_","").replace("PLUS","+")
for letter in "abcdefghijklmnopqrstuvwxyz0123456789_[]ยง": #safe since there aren't lowercases in ranks and ive never seen numbers in ranks before
rank = rank.replace(letter,"")