I am making a command where the bot can change the color of a role by command
var red = ['#ff0000']
client.on('message', message => {
var colorRole = message.mentions.roles.first() || message.guild.roles.cache.find(role => role.name === args[0].join(" "));
if(message.content.startsWith === 'grimm!change red'){
colorRole.edit({
color: red[0]
});
}})
Im having an issue where if I type the command, and then mention the role, it does not change the role color, nor does it say anything in the command prompt as well, and I have been rearranging the code.
Im also having issues with another peice of code as well
client.on('message', message => {
if (message.content.startsWith('grimm!test')) {
let colorRole = message.mentions.roles.first() || message.guild.roles.cache.find(role => role.name === args[0].join(" "));
message.channel.send(`${colorRole}`);
const roleEmbed = new Discord.MessageEmbed()
.setColor('#ff6700')
.setAuthor(colorRole)
message.channel.send(roleEmbed);
}
})
This code was used by me to test to see if my bot could recognize a role, and it worked, but everytime I accidentaly mentioned someone, the bot would give me an error and the bot would quit, is there any way to fix both of these things? I would just like the code to be able to change the color of the role that was mentioned, and it would not quit the bot if I mention a person. Thanks guys!