403 Error due to new image expiration?
Hey all, I'm unfortunately having issues with a ticket transcript system that I created for my discord bot. I've done some researching and I've come to the conclusion that I may not have access to the content I'm trying to fetch, or I've been flagged and limited.
What boggles my mind is that I never had an issue in the past 3-4 months with this approach, but I am now, so I'm more so leaning towards I'm being limited, or not requesting an image correctly for discord. I will admit it is rather primitive on how I made this function, so, apologies. Here is my code that seems to be causing my issue, as well as an abbreviated error code that I receive when calling it.
I did do some more digging and found that there was a new discord image expiration, or link / attachment expiration due to not wanting malware to be spread. Currently I am unsure how to request this new type of format with a bot.
fetchImage:
little annoying error:
Error fetching image from URL: (dicsord image url) AxiosError: Request failed with status code 403
code: 'ERR_BAD_REQUEST',
I'm fairly certain I've overlooked something rather simple, so apologies in advance, but any and all help is greatly appreciated! 😄
12 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Not a discord.js issue? Check out #other-js-ts.
- Consider reading #how-to-get-help to improve your question!
- Explain what exactly your issue is.
- Post the full error stack trace, not just the top part!
- Show your code!
- Issue solved? Press the button!
- ✅
Marked as resolved by OPDiscord.js:
14.14.1
Node:
19.0.0403 is the Forbidden code so yeah, you dont have access
Would this just be caused due to limiting? Or is it due to the new way images are handled?
What limiting are you referring to?
Its likely the expiration
That's what I was thinking, I was maybe thinkning I could've been rate limited, but I wasn't sure, so definitely looking for guidance.
https://sourceb.in/s8ArU393Mf
That's the entire class, for reference.
Greatly apologize for the spaghetti code, just been trying to do fixes.
Ratelimiting is a 429, not a 403
Gothca, 403 is just strictly forbidden access, right? I took the link that it returned and I put it in my browser and it gave me the This content is no longer available, I put it in discord and came up just fine
Also, I did try and check the discord.js website, I couldnt find anything on the new expiration, so if there's docs on it, I'd happily take a look.
I mean there isn't really anything for us to document, since this is just how discord behaves
as mentioned in #djs-help-v14, you'll want to fetch the message itself if you're trying to access it programmatically
as for why it works if you send it in discord, https://discord.com/channels/222078108977594368/992166350640386090/1157372621764182058 mentions that links in message content will automatically be updated
I think I understand, thank you Duck, I apologize I about #djs-help-v14, wasn't as clear as I could've been. I'm going to try and change the way I grab images to instead get the message, not the direct url.
Previously, I thought that was the only feasible way to do so. I'll give it a different go 🙂