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.
26 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 OPThe image on the right is what happens without using try/catch
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).
but is it OK to use catch without logging anything, or adding anything?
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
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•8mo ago
Message Not Public
Sign In & Join Server To View
nooo
I need to use nonce
I need the message ID within the nonce
Sorry, forgot to share that
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
no
wait
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
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•8mo ago
Message Not Public
Sign In & Join Server To View
What I did works
it's just the loop causing API spam
Not sure I have another way
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
The bot is for cross-server messaging
lol
hang on ill send a short clip to try and explain what it's doing
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•8mo ago
Message Not Public
Sign In & Join Server To View
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
^ working with nonce
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
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
It's not possible, messages are unique to the channel they're in
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