Is there a way to loop through each guild and channel without getting error using fetch?

Basically, right now I am using try/catch without logging the error(s), because it works. But, if I do not use try/catch, I get an "unknown message" error, even after it does return the correct message and print once.
No description
No description
26 Replies
d.js toolkit
d.js toolkit8mo ago
- 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 OP
Swyftey
SwyfteyOP8mo ago
The image on the right is what happens without using try/catch
d.js docs
d.js docs8mo ago
Documentation suggestion for @Swyftey: :mdn: Promise.prototype.catch() The catch() method of Promise instances schedules a function to be called when the promise is rejected. It immediately returns an equivalent Promise object, allowing you to chain calls to other promise methods. It is a shortcut for Promise.prototype.then(undefined, onRejected).
Swyftey
SwyfteyOP8mo ago
but is it OK to use catch without logging anything, or adding anything?
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
Swyftey
SwyfteyOP8mo ago
I want the message to be searched for within all guilds and channels thre bot is in so, it is most likely erroring when the message is NOT found within the loop
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
Swyftey
SwyfteyOP8mo ago
nooo I need to use nonce I need the message ID within the nonce Sorry, forgot to share that
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
Swyftey
SwyfteyOP8mo ago
no wait
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
Swyftey
SwyfteyOP8mo ago
I'm not trying to get that target message though I need to get the message from the ID that the targetmessage nonce contains I'm using nonce as an alternative to customID Is there any way to stop the loop once found? or avoid the API spam
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
Swyftey
SwyfteyOP8mo ago
What I did works it's just the loop causing API spam Not sure I have another way
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
Swyftey
SwyfteyOP8mo ago
The bot is for cross-server messaging lol hang on ill send a short clip to try and explain what it's doing
Swyftey
SwyfteyOP8mo ago
Swyftey
SwyfteyOP8mo ago
basically I need the original message ID, so the bot's message contains the message ID in the nonce string yes, nonce is used for "checking message delivery", but also can be used for my purpose still checks for message delivery
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
Swyftey
SwyfteyOP8mo ago
mm but when I say "original message" i mean a message the user sends within a "call" for example, the command I was working on is for "reports" if I don't get the message ID of the original message (not the one the bot sent), the report doesn't know the true details
Swyftey
SwyfteyOP8mo ago
No description
Swyftey
SwyfteyOP8mo ago
^ working with nonce
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
Swyftey
SwyfteyOP8mo ago
lol alright I think everything works and there shouldn't be a problem with it other than the loop, is there a way to check for a message within all servers/channels without causing API spam? If you don't know, no worries
Mark
Mark8mo ago
It's not possible, messages are unique to the channel they're in
Swyftey
SwyfteyOP8mo ago
nonce has a limit of 25 characters lol I'm trying to fix the loop if I can I see. But How often should you be querying to/from a database for example I would want that id to be stored for every created message within a "call" Is this OK? Ok. I guess I just didn't know if it would be possible to throttle the database or server depending on amount of requests at a time So, I would only loop through the guilds to find the channel, or does .get() on a channel ID return any channel ID from any server? I probably know this one, just double checking gotcha thanks
Want results from more Discord servers?
Add your server