Nach zufälligen Zeitpunkten bekomme ich folgende Fehlermeldung:
So sieht mein Code aus:[2022-11-01 04:19:14] [ERROR ] discord.client: Ignoring exception in on_message Traceback (most recent call last): File "C:\Users\XXX\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 409, in _run_event await coro(*args, **kwargs) File "C:\Users\XXX\Desktop\DC-BOT\Discord-Bot\main.py", line 286, in on_message fullChar = discord.File(hintCharPath, filename="image.png") File "C:\Users\XXX\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\file.py", line 97, in __init__ self.fp = open(fp, 'rb') FileNotFoundError: [Errno 2] No such file or directory: 'XXX/YYY ZZZ.jpg'
Code: Alles auswählen
embed = discord.Embed(title=helpTitle, description=helpDesc, color=helpColor)
FixPath = helpChar.replace('\u200b', '')
hintCharPath = "league/" + FixPath + '.jpg'
fullChar = discord.File(hintCharPath, filename="image.png")
embed.set_author(name="XXX", icon_url="URL")
embed.set_image(url="attachment://image.png")
await message.channel.send(file=fullChar, embed=embedLeague)
(Falls sich jemand wundert: Ich habe paar Daten wie den Pfadnamen umbenannt)
Jemand meinte ich könnte versuchen, den vollständigen Dateipfad zu parsen. Also den, den ich mit os.getcwd() erhalte. Das hat allerdings auch nicht geklappt.
Kann mir jemand weiterhelfen?