Sarenrae: Add action, spell, and item commands
This commit is contained in:
parent
961c65642e
commit
bb8cc3eb68
@ -27,12 +27,33 @@ class Sarenrae(commands.Cog):
|
||||
}
|
||||
self.conf.register_global(**default_global)
|
||||
|
||||
async def api_ping(self, category, name):
|
||||
headers = {"Authorization": await self.conf.token()}
|
||||
req = requests.get(f"https://api.pathfinder2.fr/v1/pf2/{category}?name={name}", headers=headers).json()
|
||||
return req["results"][0]["data"]["description"]["value"]
|
||||
|
||||
@commands.command()
|
||||
async def ancestry(self, ctx, *args):
|
||||
name = args[0]
|
||||
headers = {"Authorization": await self.conf.token()}
|
||||
req = requests.get(f"https://api.pathfinder2.fr/v1/pf2/ancestry?name={name}", headers=headers).json()
|
||||
html = req["results"][0]["data"]["description"]["value"]
|
||||
name = ' '.join(args)
|
||||
html = self.api_ping("ancestry", name)
|
||||
await ctx.send(file=discord.File(image(html), filename=f"{name}.jpg"))
|
||||
|
||||
@commands.command()
|
||||
async def action(self, ctx, *args):
|
||||
name = ' '.join(args)
|
||||
html = self.api_ping("action", name)
|
||||
await ctx.send(file=discord.File(image(html), filename=f"{name}.jpg"))
|
||||
|
||||
@commands.command()
|
||||
async def spell(self, ctx, *args):
|
||||
name = ' '.join(args)
|
||||
html = self.api_ping("spell", name)
|
||||
await ctx.send(file=discord.File(image(html), filename=f"{name}.jpg"))
|
||||
|
||||
@commands.command()
|
||||
async def item(self, ctx, *args):
|
||||
name = ' '.join(args)
|
||||
html = self.api_ping("equipment", name)
|
||||
await ctx.send(file=discord.File(image(html), filename=f"{name}.jpg"))
|
||||
|
||||
@commands.command()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user