Closed dylanjamesdev closed 3 years ago
Hey There, Could I please see your client options?
const client = new discord.Client({
cacheGuilds: true,
cacheChannels: true,
cacheOverwrites: false,
cacheRoles: true,
cacheEmojis: true,
cachePresences: false,
fetchAllMembers: true
});
you cannot access a value from a promise like that, the awaiting part needs to be isolated:
(await discord_data.users.fetch(i.userID)).username
also, you dont have any error handling there, you're not awaiting the second fetch and a second fetch is not needed. just do it like this:
await discord_data.users.fetch(i.userID).then(u => u.username).catch(() => "Not in Guild")
Thank you so much :)
So on the package is has this
Besides the bot user, all other Users and Members are never automatically cached. Having an incomplete user cache is not very useful most of the time, so we prefer an all-or-nothing approach. The fetchAllMembers client option can be used to cache all Users and Members, otherwise they must be manually fetched if required. Events that include some User and/or Member data usually do not require fetching as the event itself already contains enough information to provide a complete User and/or Member object.
Try fetching the user manually and tell me how that goes..
Heard thank you both, I will get back to you in a few moments
Hi there! I really love this wrapper.
Could you possibly explain why I'm unable to read usernames from this code? When console logging, it shows the user info but when putting it into code it does not.
Test:
Code: (EJS)
Notes:
discord_data
is the discord.js light client.i.userID
is a user ID string from my database.