Skip to content
This repository has been archived by the owner on Mar 25, 2020. It is now read-only.

getUser() returns undefined #276

Open
HeartHeroDE opened this issue Jun 30, 2018 · 1 comment
Open

getUser() returns undefined #276

HeartHeroDE opened this issue Jun 30, 2018 · 1 comment

Comments

@HeartHeroDE
Copy link

I am trying to receive a User object with IDs from the member list of my server because I need the additional information from the User object. However, methods including the User object are very poorly documented and the getUser() function from the client always returns undefined.

This is a little help function that I am using. I changed the memberID part with a valid userID to make sure that it's not a problem about getting the right ID. bot is a Discord.Client object.

function get_user(memberID) { var user = bot.getUser({userID: "170974398587731968"}); return user; }

The problem is that I always get undefined and there is no error message or warning about permissions. The documentation also doesn't say if the getUser function is a callback function.

I am pretty sure that it's probably just a small problem. But I can't find the answer and would appreciate some help. Thanks in advance.

@JGPenaB
Copy link

JGPenaB commented Sep 13, 2018

I had the same problem. The simple workaround is using users property of the client, which is an Object of user Objects:

function get_user(memberID) { var user = bot.users[memberID]; return user; }

Still, I can't grasp why getUser don't work, but with a simple workaround, why use it?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants