Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
164
rated 0 times [  168] [ 4]  / answers: 1 / hits: 12442  / 3 Years ago, sun, january 31, 2021, 12:00:00

I'm pretty new to Discord.js and Stackoverflow. So I don't know exactly how to do this.


I do know that this question has been asked many times, sadly any I've found haven't worked.


I'm trying to assign roles to members on their birthday. I want to do this with a crontab.
Now I have their user ID's but sadly when I request the member with this code.


let guild = client.guilds.cache.get('Guild ID');
let member = guild.members.cache.get('User ID');
console.log(member);

I just get an undefined message. Now I know that the user ID is correct. I just don't know why I get the undefined message.


More From » discord.js

 Answers
5

Instead of using:


let guild = client.guilds.cache.get('Guild ID');
let member = guild.members.cache.get('User ID');

I prefer to use something like:


let person = client.members.cache.get('User ID');
console.log(person);

If you still have problems, you will have to enable the Intents on the Discord Developers Portal


Image:


enter


[#1860] Tuesday, January 26, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tristab

Total Points: 735
Total Questions: 106
Total Answers: 96

Location: Grenada
Member since Sun, Dec 20, 2020
3 Years ago
;