UnhandledPromiseRejectionWarning: DiscordAPIError: Unknown Role in my code

Tags: , , ,



I have a few lines of code that are causing issues,

role = await message.guild.roles.cache.find(role => role.name = "Muted");
member.roles.add(role.id);

This produces the following error:

UnhandledPromiseRejectionWarning: DiscordAPIError: Unknown Role
at RequestHandler.execute (/home/runner/Marvel-Infinity-Dev-Build/node_modules/discord.js/src/rest/RequestHandler.js:154:13)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async RequestHandler.push (/home/runner/Marvel-Infinity-Dev-Build/node_modules/discord.js/src/rest/RequestHandler.js:39:14)
at async GuildMemberRoleManager.add (/home/runner/Marvel-Infinity-Dev-Build/node_modules/discord.js/src/managers/GuildMemberRoleManager.js:96:7)

I have no idea what the issue is and im really confused, any and all help is appreciated.

Answer

Dude you need to use === instead = in line 1!



Source: stackoverflow