fix !perso command
This commit is contained in:
parent
21c1bc2b32
commit
1d0d029531
@ -300,6 +300,7 @@ class WynncraftCog(commands.Cog):
|
|||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
async def quefaire(self, ctx, explicit_level: int = 0):
|
async def quefaire(self, ctx, explicit_level: int = 0):
|
||||||
|
author_id = str(ctx.author.id)
|
||||||
hints = []
|
hints = []
|
||||||
if explicit_level == 0:
|
if explicit_level == 0:
|
||||||
# check for class then quests
|
# check for class then quests
|
||||||
@ -310,10 +311,9 @@ class WynncraftCog(commands.Cog):
|
|||||||
return
|
return
|
||||||
|
|
||||||
persos = await self.config.guild(ctx.guild).persos()
|
persos = await self.config.guild(ctx.guild).persos()
|
||||||
await self._log(persos)
|
|
||||||
max_class = None
|
max_class = None
|
||||||
if ctx.author.id in persos:
|
if author_id in persos:
|
||||||
wanted_class = persos[ctx.author.id]
|
wanted_class = persos[author_id]
|
||||||
for cl in req["data"][0]["classes"]:
|
for cl in req["data"][0]["classes"]:
|
||||||
if cl["name"] == wanted_class:
|
if cl["name"] == wanted_class:
|
||||||
max_class = cl
|
max_class = cl
|
||||||
@ -436,9 +436,10 @@ class WynncraftCog(commands.Cog):
|
|||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
async def perso(self, ctx, class_str: str = None):
|
async def perso(self, ctx, class_str: str = None):
|
||||||
|
author_id = str(ctx.author.id)
|
||||||
persos = await self.config.guild(ctx.guild).persos()
|
persos = await self.config.guild(ctx.guild).persos()
|
||||||
if not class_str:
|
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])
|
await ctx.send(":white_check_mark: Ton perso défini est : %s" % persos[ctx.author.id])
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
@ -447,7 +448,7 @@ class WynncraftCog(commands.Cog):
|
|||||||
player_name = ctx.author.display_name
|
player_name = ctx.author.display_name
|
||||||
req = requests.get("https://api.wynncraft.com/v2/player/%s/stats" % player_name).json()
|
req = requests.get("https://api.wynncraft.com/v2/player/%s/stats" % player_name).json()
|
||||||
if not req["data"]:
|
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
|
return
|
||||||
|
|
||||||
valid = False
|
valid = False
|
||||||
@ -457,13 +458,12 @@ class WynncraftCog(commands.Cog):
|
|||||||
break
|
break
|
||||||
|
|
||||||
if not valid:
|
if not valid:
|
||||||
await ctx.send(":x: ce perso n'existe pas :(")
|
await ctx.send(":x: Ce perso n'existe pas :(")
|
||||||
return
|
return
|
||||||
|
|
||||||
persos[ctx.author.id] = class_str
|
persos[author_id] = class_str
|
||||||
await self.config.guild(ctx.guild).persos.set(persos)
|
await self.config.guild(ctx.guild).persos.set(persos)
|
||||||
await ctx.send(":white_check_mark: Ton perso est désormais %s !" % class_str)
|
await ctx.send(":white_check_mark: Ton perso est désormais %s !" % class_str)
|
||||||
await self._log(persos)
|
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
@checks.admin_or_permissions(manage_guild=True)
|
@checks.admin_or_permissions(manage_guild=True)
|
||||||
|
Loading…
Reference in New Issue
Block a user