0

I am trying to add the user's response into the URL. My code is

async def dungeondata():
    async with aiohttp.ClientSession(connector=aiohttp.TCPConnector(ssl=False)) as session:
        async with session.get('https://sky.shiiyu.moe/api/v2/dungeons/{}/{}'.format(name, cutename)) as resp:
            return await resp.json()

@bot.command(name='dungeon', aliases=['dungeons'])
async def dungeon(ctx, name, cutename):
    JSONData = await dungeondata(name, cutename)

When the user does ?dungeons , I am trying to add the and to the URL so the url becomes https://sky.shiiyu.moe/api/v2/dungeons/name/cutename. How do I do that?

ENORMOUZ
  • 25
  • 2
  • 11

1 Answers1

0

Add name and cutename as arguments in dungeon function.

async def dungeon(name, cutename):
    async with aiohttp.ClientSession(connector=aiohttp.TCPConnector(ssl=False)) as session:
        async with session.get('https://sky.shiiyu.moe/api/v2/dungeons/{}/{}'.format(name, cutename)) as resp:
            return await resp.json()
Just for fun
  • 4,102
  • 1
  • 5
  • 11
  • That does not work. I get the error raise CommandInvokeError(exc) from exc discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: dungeon() missing 1 required positional argument: 'cutename' – ENORMOUZ Oct 22 '20 at 03:55
  • that works, you need to pass in name and cutename when you send the command in discord – Just for fun Oct 22 '20 at 03:56
  • I did e?dungeon enormouz pineapple, but it did not work. Where name is enormouz and cutename is pineapple – ENORMOUZ Oct 22 '20 at 03:56
  • yeah rename the dungeon function to something else as its conflicting with the command name – Just for fun Oct 22 '20 at 03:57
  • I have renamed it to async def dungeondata(name, cutename): but it still does not work and i get the same error. I have edited my question so it includes the changes. – ENORMOUZ Oct 22 '20 at 03:59
  • Nevermind. I fixed the problem by adding more to the code. – ENORMOUZ Oct 22 '20 at 04:13