From 15ead53811a409e417226c1d72b09fbabb154e5e Mon Sep 17 00:00:00 2001 From: Abheek Dhawan Date: Fri, 2 Apr 2021 21:05:09 -0500 Subject: [PATCH] Use promise in rolerequest function --- index.js | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/index.js b/index.js index 05b9e56..aa3adc2 100644 --- a/index.js +++ b/index.js @@ -302,23 +302,24 @@ async function roleRequest(message) { return; } - const verificationMessage = message.channel.send(`<@${message.author.id}> would like the **${role}** role. Are they worthy?`); - message.react('👍'); - message.react('👎'); - const filter = (reaction, user) => { - return ['👍', '👎'].includes(reaction.emoji.name) && message.guild.members.cache.get(user.id).hasPermission('ADMINISTRATOR') && !user.bot; - }; - message.awaitReactions(filter, { max: 1, time: 600000000, errors: ['time'] }) - .then(userReaction => { - const reaction = userReaction.first(); - if (reaction.emoji.name === '👍') { - message.reply("wow I guess you ARE worthy! ||mods must be real mistaken||"); - message.member.roles.add(role).catch(() => { message.reply("It seems I don't have permissions to give that role, as it's likely above me :(") }); - } else { - message.reply("I guess you won't be getting that role!"); - } - }).catch(verificationMessage => { verificationMessage.edit("TIMEOUT") }); - }); + const verificationMessage = message.channel.send(`<@${message.author.id}> would like the **${role}** role. Are they worthy?`).then(message => { + message.react('👍'); + message.react('👎'); + const filter = (reaction, user) => { + return ['👍', '👎'].includes(reaction.emoji.name) && message.guild.members.cache.get(user.id).hasPermission('ADMINISTRATOR') && !user.bot; + }; + message.awaitReactions(filter, { max: 1, time: 600000000, errors: ['time'] }) + .then(userReaction => { + const reaction = userReaction.first(); + if (reaction.emoji.name === '👍') { + message.reply("wow I guess you ARE worthy! ||mods must be real mistaken||"); + message.member.roles.add(role).catch(() => { message.reply("It seems I don't have permissions to give that role, as it's likely above me :(") }); + } else { + message.reply("I guess you won't be getting that role!"); + } + }).catch(verificationMessage => { verificationMessage.edit("TIMEOUT") }); + }); + }).catch(console.error); } async function bulkDelete(message) {