discord.py AttributeError: 'ClientUser' object has no attribute 'avatar_url'?
Hi,
ich bau momentan einen discord Bot mit python der ein Formular strten soll.
Code:
@bot.command()
async def testform(ctx):
form = Form(ctx,'Title')
form.add_question('Question 1','first')
form.add_question('Question 2','second')
form.add_question('Question 3','third')
await form.start()
Error:
2023-09-09 08:58:09 ERROR discord.ext.commands.bot Ignoring exception in command testform
Traceback (most recent call last):
File "/usr/local/python/3.10.4/lib/python3.10/site-packages/discord/ext/commands/core.py", line 235, in wrapped
ret = await coro(*args, **kwargs)
File "/workspaces/moon/dir/.py/homeworkBOT/main.py", line 43, in testform
await form.start()
File "/usr/local/python/3.10.4/lib/python3.10/site-packages/discord/ext/forms/form.py", line 221, in start
embed.set_author(name=f"{self.title}: {n+1}/{len(self._questions)}", icon_url=self._bot.user.avatar_url)
AttributeError: 'ClientUser' object has no attribute 'avatar_url'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/python/3.10.4/lib/python3.10/site-packages/discord/ext/commands/bot.py", line 1350, in invoke
await ctx.command.invoke(ctx)
File "/usr/local/python/3.10.4/lib/python3.10/site-packages/discord/ext/commands/core.py", line 1029, in invoke
await injected(*ctx.args, **ctx.kwargs) # type: ignore
File "/usr/local/python/3.10.4/lib/python3.10/site-packages/discord/ext/commands/core.py", line 244, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'ClientUser' object has no attribute 'avatar_url'
Ich verstehe nicht was mit 'avatar_url' gemeint ist da ich diese nicht in meinem Code benutze.
Ich hoffe jemand kann mir helfen.
1 Antwort
Laut Fehlermeldung wir die Avatur URL in der Library aufgerufen. Eine inkompatible Library Version kann es also nicht sein.
Wenn, wegen fehlender Berechtigung oder nicht existenten Avatar, die URL nicht gesetzt wird, sollte die Library es auch ordentlich behandeln.
Ich würde eine neuere/ältere discord.py Version testen. Eventuell ist es ein Bug in der Library oder die Discord API hat sich geändert.