Browse Source

Use promise for kick

master
Abheek Dhawan 4 years ago
parent
commit
fb86d7992d
  1. 32
      index.js

32
index.js

@ -192,21 +192,23 @@ async function kick(message) {
.setThumbnail(member.user.avatarURL()) .setThumbnail(member.user.avatarURL())
.setColor("fda172") .setColor("fda172")
.setTimestamp(); .setTimestamp();
message.channel.send(verificationEmbed).catch(console.error); message.channel.send(verificationEmbed)
message.react('👍'); .then( verificationEmbed => {
message.react('👎'); verificationEmbed.react('👍');
const filter = (reaction, user) => { verificationEmbed.react('👎');
return ['👍', '👎'].includes(reaction.emoji.name) && message.guild.members.cache.get(user.id).hasPermission('ADMINISTRATOR') && !user.bot; 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: 60000, errors: ['time'] }) };
.then(userReaction => { verificationEmbed.awaitReactions(filter, { max: 1, time: 60000, errors: ['time'] })
const reaction = userReaction.first(); .then(userReaction => {
if (reaction.emoji.name === '👍') { const reaction = userReaction.first();
member.kick().then(user => message.reply(`<@${user.id}> has been kicked!`)).catch(() => message.channel.send(`Unfortunately, I don't have the ability to kick ${member.user.username}, likely because their role is higher than mine.`)); if (reaction.emoji.name === '👍') {
} else { member.kick().then(user => message.reply(`<@${user.id}> has been kicked!`)).catch(() => message.channel.send(`Unfortunately, I don't have the ability to kick ${member.user.username}, likely because their role is higher than mine.`));
message.reply(`phew! ${member}'s safe!`); } else {
} message.reply(`phew! ${member}'s safe!`);
}).catch(verificationEmbed => { verificationEmbed.edit("TIMEOUT") }); }
}).catch(verificationEmbed => { verificationEmbed.edit("TIMEOUT") });
}).catch(console.error);
} }
async function helpMessage(message) { async function helpMessage(message) {

Loading…
Cancel
Save