TypeError Cannot read properties of undefined (reading 'id')

I get the error TypeError: Cannot read properties of undefined (reading 'tag') when I try to collect users, how do I fix it?
for (let i = 0; i < 10; i++) {
let user = await interaction.guild.members.fetch(array[i].id.split('_')[2]).tag;
content += `${i+1}. ${user} - ${array[i].data}\n`
};
for (let i = 0; i < 10; i++) {
let user = await interaction.guild.members.fetch(array[i].id.split('_')[2]).tag;
content += `${i+1}. ${user} - ${array[i].data}\n`
};
3 Replies
d.js docs
d.js docs3y ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
Maxi130
Maxi1303y ago
It cannot find interaction.guild.members.fetch(array[i].id.split('_')[2]) Try printing interaction.guild.members then array, then array[i] etc. It may help us if we get the output from console.log(array) And array could be a keyword. Try renaming the array variable.
Jaworek
Jaworek3y ago
monbreyFacepalm fetch returns promise of memebr if not error
Want results from more Discord servers?
Add your server