I wanted to create my bot for economics, but I ran into a problem. What do I want to do: after writing one question, the bot waits for an answer and then asks another question and so on. Can someone help me with my problem? Currently I have something like this:
const config = require('../../config.json');
const { MessageEmbed } = require('discord.js');
const shopEconomy = require('../../database/shopEconomy');
module.exports = {
name: 'create-item',
aliases: [],
description: '',
run: async(client, message, args) => {
const items = require('../../items.json');
const item = items[Math.floor(Math.random() * items.length)];
const filter = response => {
return response.content.toLowerCase();
};
const embed = new MessageEmbed()
.setColor(`${config.correct}`)
.setAuthor({ name: `Item` })
.addFields(
{ name: `Name`, value: `---`}
)
return message.channel.send(item.question, { fetchReply: true, embeds: })
.then(() => {
message.channel.awaitMessages({ filter, max: 1, time: 10000, errors: ['time'] })
.then(async collected => {
const embed = new MessageEmbed()
.setColor(`${config.correct}`)
.setAuthor({ name: `Item` })
.addFields(
{ name: `Name`, value: `${collected.first()}`}
)
await shopEconomy.findOneAndUpdate(
{
guildID: message.guild.id,
},
{
name: `${collected.first()}`,
},
{
upsert: true,
}
);
return message.channel.send({ embeds: });
})
.catch(collected => {
const embed = new MessageEmbed()
.setColor(`${config.false}`)
.setDescription(`Timeout.`)
message.channel.send({ embeds: });
});
});
}
}