AIOHTTP мем-команда discord.py - PullRequest
1 голос
/ 08 марта 2019

Я создаю диск-бот и пытаюсь сделать случайную команду мема, а вот моя ошибка и код:

@client.command(pass_context=True)
async def meme(ctx):
    embed = discord.Embed(title="meme", description="test")

    async with aiohttp.ClientSession() as cs:
        async with cs.get('https://www.reddit.com/r/dankmemes/new.json?sort=hot') as r:
            res = await r.json()
            embed.set_image(res['data']['children'] [random.randint(0, 25)]['data']['url'])
            await client.say(embed=embed)
Ignoring exception in command meme
Traceback (most recent call last):
  File "C:\Users\atill\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\ext\commands\core.py", line 50, in wrapped
    ret = yield from coro(*args, **kwargs)
  File "C:\Users\atill\Downloads\Epic Bot\server.py", line 165, in meme
    embed.set_image(res['data']['children'] [random.randint(0, 25)]['data']['url'])
TypeError: set_image() takes 1 positional argument but 2 were given

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\atill\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\ext\commands\bot.py", line 846, in process_commands
    yield from command.invoke(ctx)
  File "C:\Users\atill\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\ext\commands\core.py", line 374, in invoke
    yield from injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\atill\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\ext\commands\core.py", line 54, in wrapped
    raise CommandInvokeError(e) from e
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: set_image() takes 1 positional argument but 2 were given

I'm not sure how to make it so it is in an embed aswell

1 Ответ

1 голос
/ 08 марта 2019

Как указано в сообщении об ошибке, функция set_image(url) принимает только 1 аргумент, а вы его дали 2. А для сообщения встраивания посмотрите на этот поток.

...