I have already resolve promises in the cardcounter function but still gives me the same [object Promise] error. I do not know which promise i should be resolving and im stuck please help me
function paginator (mainembed, max, mentioned, author) {
async function cardcounter (cardcode, user) {
const results = await printcounter.findOne({code: cardcode, printowner: user})
let finalresult = results.amounts
if (!results) {
finalresult = 0
} else {
finalresult = results.amounts
}
console.log(`Number should be: ${finalresult}`)
return Promise.resolve(finalresult).then(function(val) {
console.log(val);
});
}
var last = max
const embeds = []
for (var i = 0 ; i < mainembed.length ; i+= max) {
const sliced = mainembed.slice(i, last)
console.log(sliced)
var index = i
last += max
const cardline = sliced.map(card => ` **${card.role}** \`${card.code}\` ${card.rarity} | **${card.group}** ${card.name} (${card.theme}) - ${cardcounter(card.code, mentioned)} `).join("\n")
console.log(cardline) // will define how the line of each card will look like in the embed.
const embed = new EmbedBuilder()
.setAuthor({name: `${author.tag} - Card Book`})
.setDescription(`**Featured Member**
> <@${mentioned}>
${cardline}`)
embeds.push(embed)
}
return embeds;
} //this function will generate the enough embed needed for the cards.
I want to get a value from a document and put it in slice.map section using the cardcounter function i made. I already resolve promises in that function