I am currently attempting to write a command where you can recommend a new idea to the server. I want the command to be able (on its own) to check whenever there have been 3 of either the or the emoji. Then, the bot will delete the old message and send a new one that states whether the command has been approved or denied.
async run(client, message, args){
const channelToSend = message.guild.channels.cache.find(channel => channel.name === '-recommendations');
const Author = message.author; ;
const newEmbed = new Discord.MessageEmbed()
.setColor('#FFB6C1')
.setTitle(`Server Recommendation:`)
.setDescription(args.slice(0).join(' '))
.setAuthor(message.author.tag, message.author.avatarURL())
const errorEmbed = new Discord.MessageEmbed()
.setColor('#FFB6C1')
.setDescription('You need to reccomend something.');
const sentEmbed = new Discord.MessageEmbed()
.setColor('RANDOM')
.setDescription('Recommendation sent! Thank you.');
try {
gogo();
} catch(e) {
}
async function gogo() {
if(message.length <= '0' || message.content == null || message.content == undefined){
message.channel.send(errorEmbed);
} else{
const question = await channelToSend.send(newEmbed);
let ryC = 0;
let rnC = 0;
['', ''].forEach(async el => await question.react(el));
const collector = question.createReactionCollector(filter, { max: 4, time: 5000 });
collector.on('collect', r =>
{
if(r == ''){
ryc ++;
} else if (r == ''){
rnC ++;
}
});
collector.on('end', async collected => {
if(ryC >= rnC){
const verifiedEmbed = new Discord.MessageEmbed()
.setColor('#FFB6C1')
.setTitle(`Server Recommendation:`)
.setDescription(args.slice(0).join(' '))
.setAuthor(message.author.tag, message.author.avatarURL())
.setFooter('**Recommendation Approved**');
await question.delete();
channelToSend.send(verifiedEmbed);
}
if(rnC > ryC){
const verifiedEmbed = new Discord.MessageEmbed()
.setColor('#FFB6C1')
.setTitle(`Server Recommendation:`)
.setDescription(args.slice(0).join(' '))
.setAuthor(message.author.tag, message.author.avatarURL())
.setFooter('**Recommendation Denied**');
await question.delete();
channelToSend.send(verifiedEmbed);
}
});
}
}
}