I’m currently creating a collector in discord.js version 13.6.0. I’ve encountered such a problem that I’m checking a condition to see if the user’s message is a number, but if it’s not a number then I’d like the code to repeat until the user enters that number. I tried with a while loop but it didn’t work for me. Do you have any ideas? Below I give an excerpt of the code.
const filter = message => message.author.id == message.author.id
const mainMessage = await message.channel.send(`Jak chcesz nazwać swój przedmiot?`).catch((error) => message.channel.send(`Wystąpił nieoczekiwany błąd.n**${error}**`))
await mainMessage.channel.awaitMessages({ filter: filter, max: 1, time: 900000, errors: ['time'] })
.then(async collected => {
const itemName = collected.first().content
mainMessage.edit({ content: `Nazwa: ${itemName}nPodaj ile ma kosztować przedmiot.` })
await mainMessage.channel.awaitMessages({ filter: filter, max: 1, time: 900000, errors: ['time'] })
.then(async collected => {
const priceItem = collected.first().content
if (isNaN(priceItem.content)) {
return message.channel.send('Wprowadź liczbę!');
} else {
}
mainMessage.edit({ content: `Nazwa: ${itemName}nPieniadze: ${priceItem}.` })```