const response = await modalSubmission.reply({ embeds: [createPollEmbed(votes)], components: [row], fetchReply: true });
const collector = response.createMessageComponentCollector({ componentType: ComponentType.Button, time: 5_000 });
collector.on('collect', i => {
if (voters.has(i.user.id)) {
i.reply({content: `You've already voted on this poll!`, ephemeral: true});
}
else {
voters.add(i.user.id);
switch(i.customId){
case 'firstChoiceButton':
votes.firstChoice = votes.firstChoice += 1;
votes.total = votes.total += 1;
console.log(votes);
i.update({embeds: [createPollEmbed(votes)], components: [row], fetchReply: true})
break;
case 'secondChoiceButton':
votes.secondChoice = votes.secondChoice += 1;
votes.total = votes.total += 1;
console.log(votes);
i.update({embeds: [createPollEmbed(votes)], components: [row], fetchReply: true})
break;
case 'thirdChoiceButton':
votes.thirdChoice = votes.thirdChoice += 1;
votes.total = votes.total += 1;
console.log(votes);
i.update({embeds: [createPollEmbed(votes)], components: [row], fetchReply: true})
}
}
});
collector.on('end', i => {
i.first().editReply({content: 'hello'})
})
const response = await modalSubmission.reply({ embeds: [createPollEmbed(votes)], components: [row], fetchReply: true });
const collector = response.createMessageComponentCollector({ componentType: ComponentType.Button, time: 5_000 });
collector.on('collect', i => {
if (voters.has(i.user.id)) {
i.reply({content: `You've already voted on this poll!`, ephemeral: true});
}
else {
voters.add(i.user.id);
switch(i.customId){
case 'firstChoiceButton':
votes.firstChoice = votes.firstChoice += 1;
votes.total = votes.total += 1;
console.log(votes);
i.update({embeds: [createPollEmbed(votes)], components: [row], fetchReply: true})
break;
case 'secondChoiceButton':
votes.secondChoice = votes.secondChoice += 1;
votes.total = votes.total += 1;
console.log(votes);
i.update({embeds: [createPollEmbed(votes)], components: [row], fetchReply: true})
break;
case 'thirdChoiceButton':
votes.thirdChoice = votes.thirdChoice += 1;
votes.total = votes.total += 1;
console.log(votes);
i.update({embeds: [createPollEmbed(votes)], components: [row], fetchReply: true})
}
}
});
collector.on('end', i => {
i.first().editReply({content: 'hello'})
})