fix !perso command

This commit is contained in:
Amazed 2020-11-19 20:11:01 +01:00
parent 21c1bc2b32
commit 1d0d029531
1 changed files with 8 additions and 8 deletions

View File

@ -300,6 +300,7 @@ class WynncraftCog(commands.Cog):
@commands.command()
async def quefaire(self, ctx, explicit_level: int = 0):
author_id = str(ctx.author.id)
hints = []
if explicit_level == 0:
# check for class then quests
@ -310,10 +311,9 @@ class WynncraftCog(commands.Cog):
return
persos = await self.config.guild(ctx.guild).persos()
await self._log(persos)
max_class = None
if ctx.author.id in persos:
wanted_class = persos[ctx.author.id]
if author_id in persos:
wanted_class = persos[author_id]
for cl in req["data"][0]["classes"]:
if cl["name"] == wanted_class:
max_class = cl
@ -436,9 +436,10 @@ class WynncraftCog(commands.Cog):
@commands.command()
async def perso(self, ctx, class_str: str = None):
author_id = str(ctx.author.id)
persos = await self.config.guild(ctx.guild).persos()
if not class_str:
if ctx.author.id in persos:
if author_id in persos:
await ctx.send(":white_check_mark: Ton perso défini est : %s" % persos[ctx.author.id])
return
else:
@ -447,7 +448,7 @@ class WynncraftCog(commands.Cog):
player_name = ctx.author.display_name
req = requests.get("https://api.wynncraft.com/v2/player/%s/stats" % player_name).json()
if not req["data"]:
await ctx.send(":x: impossible de t'aider, je ne te trouve pas sur Wynncraft :(")
await ctx.send(":x: Impossible de t'aider, je ne te trouve pas sur Wynncraft :(")
return
valid = False
@ -457,13 +458,12 @@ class WynncraftCog(commands.Cog):
break
if not valid:
await ctx.send(":x: ce perso n'existe pas :(")
await ctx.send(":x: Ce perso n'existe pas :(")
return
persos[ctx.author.id] = class_str
persos[author_id] = class_str
await self.config.guild(ctx.guild).persos.set(persos)
await ctx.send(":white_check_mark: Ton perso est désormais %s !" % class_str)
await self._log(persos)
@commands.command()
@checks.admin_or_permissions(manage_guild=True)