placeholder.setColor(hexCode); message.channel.send(rolePreview).then(async (message) => { await message.react('✅'); await message.react('❌'); const filter = (reaction, user) => { return ['✅', '❌'].includes(reaction.emoji.name) && user.id === message.author.id; }; await message.awaitReactions(filter, { max: 1, time: 12000, errors: ['time'] }).then(reacts => { const reaction = reacts.first(); if (reaction.emoji.name === '✅') { const latestEmbed = message.embeds[0]; const acceptEmbed = new Discord.RichEmbed(latestEmbed) .setDescription('**Role Updated**') .setColor(message.member.displayHexColor); message.clearReactions().catch(() => {}); message.guild.createRole({ name: `USER-${message.author.id}`, color: hexCode, position: placeholder.calculatedPosition + 1 }).then(async role => { await message.member.addRole(role.id); console.log(`Role created with name: ${role.name} & color: ${role.color}`); }).catch(console.error); return message.edit(acceptEmbed).catch(() => {}); } else if (reaction.emoji.name === '❌') { const latestEmbed = message.embeds[0]; const cancelEmbed = new Discord.RichEmbed(latestEmbed) .setDescription('**Canceled**') .setColor(message.member.displayHexColor); // message.clearReactions().catch(() => {}); // role.delete('User color role deleted because of cancellation').catch(console.error); return message.edit(cancelEmbed).catch(() => {}); } }).catch(error => { const latestEmbed = message.embeds[0]; const noResponseEmbed = new Discord.RichEmbed(latestEmbed) .setDescription('**Times up**') .setColor(message.member.displayHexColor); // message.clearReactions().catch(() => {}); // role.delete('User role deleted because time\' up').catch(console.error); return message.edit(noResponseEmbed).catch(() => {}); }); }).catch(console.error);