I have a feeling it has something to do with this part of the code:
# Fetch image file
response = requests.get(image_url)
# Store image file name
image_filename = ctx.message.attachments.filename
# Caption image
final_image = caption_image(BytesIO(response.content), caption_text)
# File must be an image
if mimetypes.guess_type(image_url) not in SUPPORTED_MIMETYPES:
"Sorry, the file you attached is not a supported image format. Please"
" upload a PNG, JPEG or WebP image."
Even if the image type is correct, it still gives the ‘not in’ statement. I am unsure what is causing this. If it is user error, that is fine, but so far none of the commands I try via discord work at all.
I don’t think this link works, it lead me to a 404 page
Is your repl private? If so, please change it into public
Also, before I get access to your repl, you can try to add a print(mimetypes.guess_type(image_url)) right before the if statement you think the problem is located at (or change the print() into _ = input() to pause the program)
Always try to debug on your own using loggings (you can use icecream.ic, logging.info, _ = input, print, or anything related to output, base on your favour) before reaching out for help, it saves your time and helps you train your debugging skill
That is NOT an expiration string; it is actually a signature that Discord recently included. It is not yet enforced, so you can ignore it. However, yes, that is probably the issue. Just split it off from the URL to make it normal.
Mini Analysis for new signature:
ex: A timestamp indicating when the attachment URL will expire. After this point, you would need to retrieve another URL, such as by retrieving a message via HTTP.
is: A timestamp indicating when the URL was issued.
hm: A unique signature that remains valid until ex.
Thank you for your insight and for helping me identify the issue!
Is there some kind of function that could detach the signature from the URL? If the signature is the issue then it comes with every single discord attachment. The bot currently uses the URL created with each attachment.
A point in the right direction would be much appreciated