I have had a discord bot running for about 3 months, and today I started getting this DiscordAPIError: Unknown Member error message. It is coming from an interaction:
client.on("interactionCreate", async interaction => {
interaction.member.roles.add(<roleId>);
});
I am unable to consistently reproduce the error, but it seems like it may be coming from new members joining the server, and perhaps the discord API is not recognizing them as a guild member just yet. The server had a large influx of users today, and that's when the issue started.
Is there any way I can work around this issue, or perhaps force update the guild's member list?
The member does not seem to be properly cached. Before accessing it, use await interaction.member.fetch()
client.on("interactionCreate", async interaction => {
await interaction.member.fetch()
interaction.member.roles.add(roleId)
})