简体   繁体   中英

How do you properly set a thumbnail for an embed in discord.py?

I'm having trouble with this line of code for a discord.py bot:

content.set_thumbnail(url=ctx.author.avatar_url)

When I run this bot on my local computer, the embed appears properly, but I get the following error when I push the same code to Heroku:

2021-05-02T16:02:41.514038+00:00 app[worker.1]: Traceback (most recent call last):
2021-05-02T16:02:41.514096+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.9/site-packages/discord/ext/commands/bot.py", line 965, in invoke
2021-05-02T16:02:41.514096+00:00 app[worker.1]:     await ctx.command.invoke(ctx)
2021-05-02T16:02:41.514179+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.9/site-packages/discord/ext/commands/core.py", line 798, in invoke
2021-05-02T16:02:41.514180+00:00 app[worker.1]:     await injected(*ctx.args, **ctx.kwargs)
2021-05-02T16:02:41.514205+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.9/site-packages/discord/ext/commands/core.py", line 123, in wrapped
2021-05-02T16:02:41.514206+00:00 app[worker.1]:     raise CommandInvokeError(exc) from exc
2021-05-02T16:02:41.514257+00:00 app[worker.1]: discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Member' object has no attribute 'avatar_url'

Any ideas?

The mistake is that this function can only be injected:
Correct answer:

embed.set_thumbnail (url = channel.member.avatar_url)

You will find a bunch of embedded videos like this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM