HarleyErza
HarleyErza
DIAdiscord.js - Imagine an app
Created by HarleyErza on 2/7/2024 in #djs-questions
Cannot read properties of undefined (reading `fetch`)
I'm trying to add a role to a newly joined user, after parsing their display name through an external API. However, I get an error stating that I cannot read the properties of undefined (reading fetch). const { Guild, GuildMember } = require('discord.js');
client.on(Events.GuildMemberAdd, async guildMember => {
await IsInOutfit(guildMember);
})
client.on(Events.GuildMemberAdd, async guildMember => {
await IsInOutfit(guildMember);
})
...
function AssignRole(guildMember, role)
{
guildMember.roles.add(Guild.roles.fetch(roles));
}
function AssignRole(guildMember, role)
{
guildMember.roles.add(Guild.roles.fetch(roles));
}
A quick note on GuildMember: according to VSCode, it's value is unused. I do not get why. Node version: v18.15.0
14 replies