find user, in the cache or not ?
Hello !
I'm doing a lot of commands that are fetching for a target user and I'm using atm these functions :
-
client.users.fetch(id);
-message.guild.members.fetch(targetUserId);
However I realize that this one throws exceptions when it does not find any user which I find a bit disturbing (putting try-catch everywhere is not very fun)
I also see some peoples fetching from the cache of the client or the guild and fetch in this way does not seem to generate an Exception.
But before going from one to the other way, I would like to know what is the difference between cached and non-cached data. Is there even one ? And does this somehow impact the search for fetch()
functions ?3 Replies
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
<:KleeOK_GreenTea:782407596778061835> Alright, thanks a lot !
So if I understand correctly, I should always use the cache ? Or does it only depend on whether I want it to raise an exception or not ? Are there cases where we will always prefer one over the other?
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View