const getNumberOfQuestions = async () => {
await this.channel.send('How many questions should I ask? (1-10)')
.then(async message => {
await this.channel.awaitMessages(message => message.author.id === this.owner && !isNaN(parseInt(message.content)), { max: 1, time: 15000 })
.then(collected => {
this.channel.send(`You asked for ${collected.first().content} questions.`);
return parseInt(collected.first().content);
})
.catch(collected => {
this.channel.send('You did not tell me how many questions you wanted. Ending the quiz.');
});
});
};
const getDifficulty = async () => {
await this.channel.send('What difficulty would you like: easy, medium, hard?')
.then(message => {
this.channel.awaitMessages(message => message.author.id === this.owner && ['easy', 'medium', 'hard'].includes(message.content.toLocaleLowerCase()), { max: 1, time: 15000 })
.then(collected => {
this.channel.send(`You asked for ${collected.first().content} difficulty.`);
return collected.first().content;
})
.catch(collected => {
this.channel.send('You did not tell which difficulty you wanted. Ending the quiz.');
});
});
};
getNumberOfQuestions();
getDifficulty();
With the above code, I do not want the execution to continue past this function when it is called. I clearly do not understand promises and await can some one help me?
.send
and .awaitMessages
both return a promise