Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
289 views
in Technique[技术] by (71.8m points)

javascript - UnhandledPromiseRejectionWarning: DiscordAPIError: Unknown Role in my code

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.

question from:https://stackoverflow.com/questions/65866590/unhandledpromiserejectionwarning-discordapierror-unknown-role-in-my-code

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...