I have a problem with assigning a role after clicking the appropriate response.
When the user responds to the message, no role is assigned and no message or error pops up in the console.
At this point, the role is not added, but a message pops up for the saved “Error adding role”. UPDATE:
client.on(“messageReactionAdd”, ({ message: { channel } }, user) => {
if (/weryfikacja/.test(channel.name)) {
channel.guild.members
.fetch(user)
.then(member => {
member.roles
.add(‘930796894026883153’)
.then(() => {
console.log(
The ${roleName} has been removed from member ${user.tag} successfully!
);
})
.catch(e => console.error(“Error adding role”));
})
.catch(error => {
console.error(error);
});
}
});
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
If a role is not being assigned, and you aren’t seeing any errors in the console, there are a few potential issues to look at. Here are a couple of possibilities:
In your case, make sure that channel.name indeed contains the string ‘weryfikacja’, otherwise the function won’t execute. Also, consider adding console.log() statements at various points in your code for a better understanding of where the function fails.
If you are still having issues, ensure that you have the necessary node and discord.js versions. Check if promises are working correctly, especially since some libraries return promises that should eventually resolve or reject.
For additional assistance, check out this How To Build a Discord Bot with Node.js on DigitalOcean tutorial.
Hope that this helps!
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.